开发者

Pushing a new viewcontroller via a next button?

Sorry I can't show code for this question - it should be fairly simple to explain..

I have an array of data (object1, object2, object3, etc)… I have one tableview that lists these objects (object1.title, object2.title, etc) and upon clicking it push's a viewcontroller that shows the detail of each object. Now, rather than have to press Ba开发者_如何学编程ck on each detail view, I'd like to put a next button on the detail page..

I could easily push a new controller, however it would end with a chain of:

List View -> Detailview1 -> Detailview2, etc..

which would be a pain to traverse back up the stack.. Can the parent view controller be removed / changed easily or is this not the best way to do it?

Cheers.


You can always pop back to a specific index in the stack. So you could have a back button that pops back to the parent. If there is no real reason that the user would need to go back through the detail view controllers you could swap controllers by replacing the stack with a new stack using setViewControllers:animated: Look through the UINavigationController documentation and see whats possible.


This code will "pop" the view contoller off the view, so it removes it, instead of overlaying another view on top of it. Add this to your button action

 [self.navigationController popViewControllerAnimated:YES];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜