IOS - XCode 4 - iPhone 6.0 - Add back button to subview -


caution: n00b @ ios development. have read several tutorials , code snippets on past 10 days or so, , have gleaned enough info dangerous. trying accomplish open webview (as sub-view) user login, reason nav controller not displaying button. i've tried few different things no avail, doing wrong, seeking guidance.

my nav controller set root controller, , next on stack epviewcontroller. view controller starting point of app. view have 2 buttons, 1 login, , 1 enter data (inconsequential question).

epviewcontroller code snippet:

- (ibaction)buttontologinview:(id)sender {     uiwebview *webview = [[uiwebview alloc] initwithframe:self.view.bounds];      [webview loadrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:@"http://example.com/wsapi/user/login"]]];      [self.view addsubview:webview]; } 

this works great, sub-view shows nav bar , remote login page, no button. based on other code snippets tried following (within same epviewcontroller file):

- (void)viewdidload {     [super viewdidload]; // additional setup after loading view, typically nib.      uibarbuttonitem *backbutton = [[uibarbuttonitem alloc] initwithtitle:@"back???" style:uibarbuttonitemstyleplain target:nil action:nil];      self.navigationitem.backbarbuttonitem = backbutton; } 

but custom button gets added if click the button enter data (actually goes concrete view controller vs subview).

what need add button subview? advisable use subview here, should instead link concrete view controller?

think of navigation controller container of actual view controllers. in sense, navigation controller isn't "first on stack", epviewcontroller being "next on stack". instead, navigation controller is actual stack, epviewcontroller being first (and only) item. when app launches, navigation controller presents root view controller, see onscreen. when call navigation controller's pushviewcontroller: method, new view controller pushed onto stack, , button shown.

in case, recommend not showing web view subview on main view. instead, put in own view controller. in view controller, may add button attempted formerly. present view controller modally using [self presentmodalviewcontroller:]. feel more organized , fluid user, , avoids business of fiddling subviews on main view.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -