uiview - Unable to display view when I call it from a separate ViewController in iOS -


i have view controller in application on screen have uiview user required tap on. when that, want call viewcontroller's view, , display on screen user. unfortunately, having trouble displaying view.

the name of viewcontroller making call called "mainviewcontroller", , viewcontroller view wish display called, "nextviewcontroller"

here code make call:

- (void) touchesbegan:(nsset *)touches withevent:(uievent *)event {      nslog(@"i touched.");      _nextview = [[nextviewcontroller alloc] init]; //this code not being called     [self.view addsubview:_nextview.view];         //neither being called  } 

where _nextview property declare in .h file of mainviewcontroller.

this method being called, reason because able see log statements print output, reason unable call lines after that. can see i'm doing wrong?

thanks in advance reply.

you shouldn't add view of view controller view without making view controller child view controller. if want view, set 1 in xib file , add view subview. if want use view controller, should present modally, , dismiss when you're done. kind of situation want gather info user use in app, appropriate place use modal view controller. mainviewcontroller should set delegate of nextviewcontroller, , nextviewcontroller should define delegate protocol send data mainviewcontroller.

to present modally, this:

_nextview = [[nextviewcontroller alloc] initwithnibname:@"your nib name here" bundle:nil]; [self presentviewcontroller:_nextview animated:yes completion:nil]; 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -