objective c - Can't pop iOS viewController. Not sure, but I think it's something with the Navigation Controller -


i'm having trouble trying pop view

app delegate

@implementation maappdelegate @synthesize navcontroller; @synthesize detailviewcontroller;  - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];      // init navcontroller master detail view of grade cells      uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] init];       detailviewcontroller = [[uiviewcontroller alloc] init]; //step6     navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:[[macontroller alloc] init]]; //step7       self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];     self.window.backgroundcolor = [uicolor whitecolor];     self.window.rootviewcontroller = navcontroller; //step8     [self.window makekeyandvisible];       // set macontroller rootviewcontroller     //self.window.rootviewcontroller = [[macontroller alloc] init];     self.window.backgroundcolor = [uicolor whitecolor];     [self.window makekeyandvisible];         // use insanely cool tsmessages show network alerts     [tsmessage setdefaultviewcontroller: self.window.rootviewcontroller];     return yes; } 

first part of viewcontroller

- (void)viewdidload {     [super viewdidload];     // additional setup after loading view.       [self.navigationcontroller setnavigationbarhidden:yes];     uibarbuttonitem *newbackbutton = [[uibarbuttonitem alloc] initwithtitle:@"home" style:uibarbuttonitemstylebordered target:self action:@selector(home:)];     self.navigationitem.leftbarbuttonitem=newbackbutton; 

later, when change viewcontroller

    nslog(@"opened progress report");      uiviewcontroller *detailviewcontrol = [[uiviewcontroller alloc] init];      // set progress report view controller     [self.navigationcontroller pushviewcontroller:detailviewcontrol animated:yes];      uiimage *background = [uiimage imagenamed:@"bg"];      // add static image bg     self.backgroundimageview = [[uiimageview alloc] initwithimage:background];     self.backgroundimageview.contentmode = uiviewcontentmodescaleaspectfill;     [self.view addsubview:self.backgroundimageview];      // add blurred layer image when tableview goes in front of     self.blurredimageview = [[uiimageview alloc] init];     self.blurredimageview.contentmode = uiviewcontentmodescaleaspectfill;     self.blurredimageview.alpha = 0;     [self.blurredimageview setimagetoblur:background blurradius:10 completionblock:nil];     [self.view addsubview:self.blurredimageview];        [self.navigationcontroller setnavigationbarhidden:no]; 

so don't understand why when this, selector button (that know fires, because righthtere in log):

    -(void)home:(uibarbuttonitem *)sender {     nslog(@"righthtere");     // set progress report view controller     [self.navigationcontroller poptoviewcontroller:self animated:yes];      } 

it doesn't go initial view controller.

you seem confusing poptoviewcontroller , popviewcontrolleranimated. popviewcontrolleranimated removes current view stack , brings new stack top active view controller. poptoviewcontroller pops stack until listed view controller on top of stack.

since calling poptoviewcontroller self, , see requested view controller on top of stack , nothing. if wish go 1 view controller call should be.

[self.navigationcontroller popviewcontrolleranimated:yes]; 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -