SwipeView icon indicating copy to clipboard operation
SwipeView copied to clipboard

Two swipeViews on the screen?

Open pahnev opened this issue 10 years ago • 4 comments

Is it possible to have two or more swipeViews on the screen but having different data in them?

Something like this:

if (swipeView == firstSwipeView) {
    view = [[NSBundle mainBundle] loadNibNamed:@"FirstSwipeView" owner:self options:nil][0];
    // Do additional stuff
 } else {
    view = [[NSBundle mainBundle] loadNibNamed:@"SecondSwipeView" owner:self options:nil][0];
}

pahnev avatar Dec 02 '14 19:12 pahnev

Yes. You'd do it like that.

nicklockwood avatar Dec 02 '14 20:12 nicklockwood

It would be easier and best practise to have multiple data source classes and set those as the delegate and data source for the appropriate swipe view. That way you keep everything separate and encapsulated. Then if you change your mind later or want to reuse the source you can more easily.

On 2 Dec 2014, at 19:09, Kirill Pahnev [email protected] wrote:

Is it possible to have two or more swipeViews on the screen but having different data in them?

For example first one would load from

if (swipeView == firstSwipeView) { view = [[NSBundle mainBundle] loadNibNamed:@"FirstSwipeView" owner:self options:nil][0]; // Do additional stuff } else { view = [[NSBundle mainBundle] loadNibNamed:@"SecondSwipeView" owner:self options:nil][0]; } — Reply to this email directly or view it on GitHub.

pjcook avatar Dec 02 '14 20:12 pjcook

That's also true :-)

nicklockwood avatar Dec 02 '14 20:12 nicklockwood

I just tried my code again and it worked. Guess I had a typo or something before. Maybe I'll try that other method too as it would eliminate a lot of if-statements.

pahnev avatar Dec 02 '14 21:12 pahnev