Reputation: 3512
My problem is: I have a list(UITableView) of news in my application When I clicking on 1 'new' I opening it and I have a back button inside it that can get me back to the list. Now the issue is I have to implement on swipe 'new' change so I made my gesture recogniser etc ..
the problem is: I have tried to use
[self presentViewController:previousNew animated:YES completion:Nil];
to present the previous new
but I think it is obviously for you that when I clicking on back button inside the new instance of new it brings me back to the old new instead of bringing me back to the gallery.
here is my code inside gesture recognition
if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft)
{
NSLog(@"get gesture Left");
NSUserDefaults* defauts = [NSUserDefaults standardUserDefaults];
NSMutableArray* newsArray = [defauts objectForKey:@"NewsArray"];
if(_index +1 < [newsArray count])
{
NewsDetailsViewController* previousNew = [[NewsDetailsViewController alloc]initWithParameter:_index+1];
// [self.navigationController pushViewController:previousNew animated:YES];
//[self.navigationController presentModalViewController:previousNew animated:YES];
[self presentViewController:previousNew animated:YES completion:Nil];
}
else
return;
}
and here is my back button code
-(void)Back
{
NSLog(@"atBack");
[self dismissModalViewControllerAnimated:YES];
}
Please every help will be highly appreciated (This is my first iOS application so please don't get mad on me I am lack of experience). Note I am using ARC and NOT using interfaceBuilder
Upvotes: 1
Views: 473
Reputation: 2256
Everytime you swipe, you just presented another ViewController on the top of the old new. Thats why when you click Back button, it brings you back to the old new rather than the list.
What I can suggest is, you can use a scrollview which has three pages showing the previous new, current new (the new that you clicked on the list), and the next new. And when you swipe, just adjust the three views to the correct ones. For example, you clicked the 3rd new on the lsit, then the scrollview will be showing the 3rd new (of course) with the 2nd new on the left and the 4th new on the right. Then you swipe to the 2nd new (which is the previous one), now the scrollview is showing the 2nd new (of course) with the 1st new on the left and the 3rd new on the right.
Upvotes: 1