objective c - UIViewController view disappears when I change a view frame iOS 8 -
this code ios 7 works fine, when runs in xcode 6 & ios8 simulator, view disappears (uiviewcontroller viewwilldisappear called) after make small change self.webview.frame. happens when select "edit" option actionsheet. however, when tap webview , notify/call keyboardwillshow:, not disappear. uiviewcontroller presented rootviewcontroller modalpresentationstyle:uimodalpresentationformsheet i'd appreciate help.
- (void)actionsheet:(uiactionsheet *)actionsheet clickedbuttonatindex:(nsinteger)buttonindex{ nsstring *title = [actionsheet buttontitleatindex:buttonindex]; if([title isequaltostring:@"edit"]){ [self switchmodeto:@"edit"]; } } - (void)switchmodeto:(nsstring *)mode{ if([mode isequaltostring:@"edit"]){ self.iseditmode = yes; [self.btnapply sethidden:no]; [self.btnmore sethidden:yes]; cgrect frame = [self.webview frame]; frame.origin.y = 44; frame.size.height = 492; [self.webview setframe:frame]; } } - (void)keyboardwillshow:(nsnotification *)notif{ [self switchmodeto:@"edit"]; }
i had similar problem. attempted present modal view controller triggered action sheet. modal view presented, , dismissed.
i created test case, , received following message:
warning: attempt present <modalviewcontroller: 0x78fbadd0> on <mainviewcontroller: 0x78fa71c0> presenting (null) it turned out action sheet popover interfering view controller's ability present modal view controller. example, if triggered same code other action sheet (in case, button), worked fine.
to resolve issue, introduced small delay give action sheet popover chance out of way, in example:
- (void)actionsheet:(uiactionsheet *)actionsheet clickedbuttonatindex:(nsinteger)buttonindex { if ( buttonindex != actionsheet.cancelbuttonindex ) { [self performselector:@selector(showmodalview) withobject:nil afterdelay:0.3]; } } - (void)showmodalview { modalviewcontroller* modalvc = [[modalviewcontroller alloc] init]; [self presentviewcontroller:modalvc animated:yes completion:nil]; }
Comments
Post a Comment