开发者

Bar button issue when reusing table class

开发者 https://www.devze.com 2023-04-11 09:39 出处:网络
I\'m using a table view in my app.It\'s Delegate and datasource all are in the same class RootviewController.

I'm using a table view in my app.It's Delegate and datasource all are in the same class RootviewController. When user clicks a cell, I reuse the same class RootViewController for displaying next table with content. User can click to navigate for 4 times in the table and it'll navigate to next view. But unfortunately when user clicks the first time, it'll navigate to next table view, but it won't display the back button. For the remaining clicks it works fine and displays the back button. Also user cannot navigate back to first view.

RootViewController *root = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
  [root setNext:temp.previousCategory];
  [root setTitle:temp.Category]开发者_JAVA百科;
  temp = nil;
   [self.navigationController pushViewController:root animated:YES];

I'm totally confused about it, please help me.


Maybe

root.navigationItem.hidesBackButton = NO;

Also you might have to give the navigation item of the controller a title so that the back button has something to display (do this before pushing the view controller)

self.navigationItem.title = @"Root";


You really should split out the data handling part of your code into a separate class or object apart from the RootViewController.

That way, your code will likely be more manageable, you'll be able to push new view controllers, and most importantly, pushing new views will provide "back" buttons as the user would expect.

0

精彩评论

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

关注公众号