ios - removing a view controller on click of a button -
i developing library ios app authenticate users on basis of credential entered them.
what doing that, view controller testviewcontroller
setting new view controller loginscreenviewcontroller
on top of testviewcontroller
when user taps button using following code.
loginscreenviewcontroller * loginscreen = [[loginscreenviewcontroller alloc] initwithnibname:nil bundle:nil]; [self.view addsubview:loginscreen.view];
this loginscreenviewcontroller
contains cancel
button, on want remove loginscreenviewcontroller
. using following code
[self.view removefromsuperview];
the problem when executing code, app crashing.
since loginscreenviewcontroller
defined library, want independent of caller's implementation.
edit:
in loginscreenviewcontroller.m
have used following code add event handler cancel button.
[button addtarget:self action:@selector(cancelbuttonhandler:) forcontrolevents:uicontroleventtouchupinside];
the app crashing when tapping cancel
button. if cancelbuttonhandler
not contain line of code.
you trying remove wrong view. remove loginscreen view do:
[loginscreen.view removefromsuperview];
Comments
Post a Comment