ios - Cancel button not showing up in UINavigationController in modal for iPad -


i'm trying add cancel button modal in navigation bar ipad.

i'm using following code:

    uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:abpersoncontroller];     navcontroller.navigationitem.leftbarbuttonitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemcancel                                                                                           target:self                                                                                           action:@selector(dismissmodal)];     [self presentviewcontroller:navcontroller animated:yes completion:nil]; 

for reason though, cancel button not show up.

using spark inspector, i'm seeing indicator cancel button supposed hidden, , when run in on ipad simulator, cannot see cancel button or indicator.

i tried setting indicator's hidden property no nothing shows up.

edit: way can work if add button in completion block:

[self presentviewcontroller:navcontroller animated:yes completion:^{abpersoncontroller.navigationitem.leftbarbuttonitem = donebutton;}]; 

but solution looks bad because done button pops in after modal has been on screen. there other ways doesn't have in completion block?

edit:

        uiviewcontroller *dummyview = [[uiviewcontroller alloc] init];         uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:dummyview];         [navcontroller pushviewcontroller:abpersoncontroller animated:no];         abpersoncontroller.navigationitem.hidesbackbutton = yes;         abpersoncontroller.navigationitem.leftbarbuttonitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemcancel                                                                                               target:self                                                                                               action:@selector(dismissmodal)];         navcontroller.modalpresentationstyle = uimodalpresentationformsheet;         navcontroller.modaltransitionstyle = uimodaltransitionstylecrossdissolve;         [self presentviewcontroller:navcontroller animated:yes completion:nil];         navcontroller.view.superview.bounds = cgrectmake(0, 0, 320, 480); 

should backbarbuttomitem instead of leftbarbuttomitem.

uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:abpersoncontroller]; navcontroller.navigationitem.backbarbuttonitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemcancel                                                                                       target:self                                                                                       action:@selector(dismissmodal)]; [self presentviewcontroller:navcontroller animated:yes completion:nil]; 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -