导航控制器将我的视图推两次?
我有一个 UITableViewController,它在单击单元格时推送一些视图:
switch(indexPath.row) {
case kFollowerSectionUpdatesCountRow:
stockTwitsView.reloadUpdates = TRUE;
stockTwitsView.showHomeButton = TRUE; //** reversed, true means hide the button
stockTwitsView.profileName = self.user_name;
stockTwitsView.msgSource = self.message_source;
[self.navigationController pushViewController:stockTwitsView animated:YES];
break;
case kFollowerSectionFollowerCountRow:
followSectionDetailView.username = self.user_name;
followSectionDetailView.loadFollowers = TRUE;
[self.navigationController pushViewController:followSectionDetailView animated:YES];
break;
case kFollowerSectionFollowingCountRow:
followSectionDetailView.username = self.user_name;
followSectionDetailView.loadFollowing = TRUE;
[self.navigationController pushViewController:followSectionDetailView animated:YES];
break;
}
一切正常,除了 kFollowerSectionUpdatesCountRow 之外。它将推动视图,但如果我单击后退按钮,它会再次加载相同的视图而不是返回?我必须再次单击“返回”才能返回到原始屏幕。如果推动任何其他观点,则不会发生这种情况。
不知道为什么?
更新: 奇怪的是这个部分是我的 UITableView 的第三部分。如果我将其更改为第二部分,则视图控制器只会被推送一次。为什么?
I have a UITableViewController that is pushing some views when clicking on a cell:
switch(indexPath.row) {
case kFollowerSectionUpdatesCountRow:
stockTwitsView.reloadUpdates = TRUE;
stockTwitsView.showHomeButton = TRUE; //** reversed, true means hide the button
stockTwitsView.profileName = self.user_name;
stockTwitsView.msgSource = self.message_source;
[self.navigationController pushViewController:stockTwitsView animated:YES];
break;
case kFollowerSectionFollowerCountRow:
followSectionDetailView.username = self.user_name;
followSectionDetailView.loadFollowers = TRUE;
[self.navigationController pushViewController:followSectionDetailView animated:YES];
break;
case kFollowerSectionFollowingCountRow:
followSectionDetailView.username = self.user_name;
followSectionDetailView.loadFollowing = TRUE;
[self.navigationController pushViewController:followSectionDetailView animated:YES];
break;
}
Everything works fine, except for kFollowerSectionUpdatesCountRow
. It will push the view, but if I click the back button, it loads the same view again instead of going back? I have to click back again in order to get back to my original screen. This does not happen with any of the other views being pushed.
Not sure why?
UPDATE:
What is odd is this section is the 3rd section of my UITableView. If i change it to the 2nd section, the view controller only gets pushed once. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您很可能会推动视图控制器两次。从这段代码片段中很难看出,但请检查 stockTwitsView 视图控制器中的 viewWillAppear 调用,看看它出现了多少次(以及它们是否是不同的、唯一的对象)。
Chances are you're pushing the viewcontroller twice. Difficult to see from this code snippet, but check out viewWillAppear calls in your stockTwitsView view controller to see how many times it's appearing (and whether they are different, unique objects).
当你要“返回”时,你是否有机会调用pushViewController?
如果是这样,请不要这样做。导航回父调用者时无需调用 PushViewController。
Are you by any chance calling pushViewController when you are going 'back'?
If so, don't do that. No need to call pushViewController when navigating back to parent caller.