iphone - UIViewcontroller is not presented in correct orientation -
i presenting view controller view controller using presentviewcontroller
.
the presenting view controller (the "sourceviewcontroller") creates new view controller , assigns navigation controller before presentation (because "nextviewcontroller" wants navigation bar , navigation controller).
// source view controller @implementation sourceviewcontroller -(void)shownextviewcontroller { nextviewcontroller *viewcontroller = [[nextviewcontroller alloc] init]; uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:viewcontroller]; [self presentviewcontroller:viewcontroller animated:yes]; } @end @implementation nextviewcontroller // in nextviewcontroller - (nsuinteger)supportedinterfaceorientations { homecoming uiinterfaceorientationportrait; } - (uiinterfaceorientation)preferredinterfaceorientationforpresentation { homecoming uiinterfaceorientationportrait; } @end
but when nowadays view controller when originating view controller in landscape "nextviewcontroller" isn't presented in portrait rather in landscape source view controller.
i've tried many combinations of rotation methods haven't been able nowadays in right orientation.
i assume possible because many apple components uiimagepickercontroller presented in portrait , how forcefulness orientation?
thanks
edit:
i've created uinavigationcontroller
sub class:
portraitnavigationcontroller : uinavigationcontroller @implementation -(bool)shouldautorotate { homecoming no; } - (uiinterfaceorientation)preferredinterfaceorientationforpresentation { homecoming uiinterfaceorientationportrait; } @end
and when presenting nextviewcontroller
portraitnavigationcontroller *nav = [portraitnavigationcontroller initwithrootviewcontroller:nextviewcontroller]; [self presentviewcontroller:nav animated:yes];
and nextviewcontroller
indeed in portrait - when rotate device utilize view controller , dismiss - underlying source view controller looks messed up.
the underlying view controller custom container view controller embedded in uinavigationcontroller
the containers uses display kid view controllers not in right places
i don't want container view controller rotate @ nextviewcontroller
displayed , dismissed.
when rotate device presented view controller asked rotations , orientations supports - in case it's uinavigationcontroller , not instance of nextviewcontroller. 1 way prepare subclass uinavigationcontroller , override rotation methods , forwards calls onto it's root view.
as side not uiimagepickercontroller subclass of uinavigationcontroller. might create more sense create nexviewcontroller subclass of uinavigationcontroller , within subclass initialize right root view controller.
another alternative alloc , init uinavigationbar within of nextviewcontroller , add together subview if don't need utilize navigation controller anything. in case autolayout comes in handy because can pin top, left, , right , allow figure out right size , location it.
iphone objective-c uiviewcontroller uinavigationcontroller uiinterfaceorientation
No comments:
Post a Comment