Sheehan Alam
Sheehan Alam

Reputation: 60859

Navigation Controller pushing my view twice?

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?

Upvotes: 1

Views: 4015

Answers (2)

ChrisH
ChrisH

Reputation: 924

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).

Upvotes: 2

AlvinfromDiaspar
AlvinfromDiaspar

Reputation: 6822

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.

Upvotes: 0

Related Questions