ios - Supporting multiple orientations on a single view controller -


i trying pretty simple thing: support horizontal orientation in app, except 1 stack of view controllers. simplicity, lets have 2 uiviewcontrollers. lets call them masklandscapevc , maskallvc. each separately embedded in own instance of custom uinavigationcontroller. here code navigation controller.

#import "mptloginnav.h"  @interface mptloginnav ()  @end  @implementation mptloginnav  - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self) {         // custom initialization     }     return self; }  - (void)viewdidload {     [super viewdidload];     // additional setup after loading view. }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. }  #pragma mark #pragma interface orientaiton methods  - (nsuinteger)supportedinterfaceorientations {     if (self.ismaskallstack)         return uiinterfaceorientationmaskall;      return uiinterfaceorientationmasklandscape; }  - (bool)shouldautorotate {     return yes; }  @end 

on masklandscapevc, code works fine , 2 horizontal orientations can used. users can navigate masklandscapevc maskallvc. following code takes care of that

uistoryboard *storyboard = [uistoryboard storyboardwithname:@"storyboard" bundle:[nsbundle bundleforclass:[self class]]]; self.maskallvc = [storyboard instantiateviewcontrollerwithidentifier:@"maskallvc"]; [self.navigationcontroller pushviewcontroller:self.maskallvc animated:yes]; 

at maskallvc, code works great , 4 orientations supported.

once on maskallvc, user switches vertical orientation. masklandscapevc delegate of maskallvc. while in vertical orientation on maskallvc, user presses button. button call delegate (masklandscapevc), based on conditions, masklandscapevc decides dismiss maskallvc. uses following code

[self.maskallvc.navigationcontroller popviewcontrolleranimated:yes]; [self.maskallvc.navigationcontroller dismissviewcontrolleranimated:yes completion:nil]; 

now on masklandscapevc, orientation still vertical , of course view messed because of it.

i think because pop go doesn't refresh whole viewcontroller first time. using viewdidload instead of viewwillappear might problem. viewdidload called once.

do complete layoutsubview refresh if set breakpoints? call supportedinterfaceorientations @ when pop? happens if move viewdidload code viewwillappear?


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -