导航控制器将我的视图推两次?

发布于 2024-09-10 20:22:42 字数 1520 浏览 2 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽心 2024-09-17 20:22:42

您很可能会推动视图控制器两次。从这段代码片段中很难看出,但请检查 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).

拥有 2024-09-17 20:22:42

当你要“返回”时,你是否有机会调用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文