i have 2 view (view 1 , view 2). view1 contain button , when clicked on button go view 2. want show view2 orientation portrait , landscape. view2 create 2 uiviewcontroller 1 landscape orientation , seconde portrait orientation , same same class.but not work. 1 have idea?
- (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { // return yes supported orientations return uiinterfaceorientationislandscape(interfaceorientation); }
why need two viewcontrollers purpose of orientation ..?
here simple scenario ,
create 2 views
- portrait &&
- landscape view , per requirement .
follow .
-(bool)shouldautorotate{ return yes; } - (void) willrotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation duration:(nstimeinterval)duration { [self orientationchanged:tointerfaceorientation]; } -(void)orientationchanged:(uiinterfaceorientation)orientation{ nslog(@"orientation change"); // uideviceorientation deviceorientation = [[object object] orientation]; if(orientation == uiinterfaceorientationportrait || orientation == uiinterfaceorientationportraitupsidedown){ nslog(@"changed orientation portrait"); self.viewportrait.hidden = no; self.viewlandscape.hidden = yes; } else if(orientation == uiinterfaceorientationlandscapeleft || orientation == uiinterfaceorientationlandscaperight){ nslog(@"changed orientation landscape"); self.viewportrait.hidden = yes; self.viewlandscape.hidden = no; } } and should set orientation required .
-(nsuinteger)supportedinterfaceorientations { return uiinterfaceorientationmaskall; }
Comments
Post a Comment