开发者

Orientation Methods not responding when one view controller view is added as sub view

I am developing an application in which on my button click I have to show one class controller view as a sub view. I have added my view Controller as sub view and it works fine.

TempViewControlleriPad *tempScreen=[[TempViewControlleriPad alloc]initWithNibName:@"TempViewControlleriPad" bundle:nil];
[self.view addSubview:tempScreen.view];
[tempScreen viewWillAppear:NO];

Now when I rotate my device orientation then my sub view did not respond to that orientation means that my sub view did not rotate.

TempViewControlleriPad orientation method:-


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
             [[NSBundle mainBundle] loadNibNamed:@"TempViewControlleriPad" owner:self options:nil];
    }
    else if(interface开发者_运维知识库Orientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
         [[NSBundle mainBundle] loadNibNamed:@"TempViewControlleriPadLandscape" owner:self options:nil];
    }

    return YES;

}

Please suggest me what should I do to solve this orientation problem.

Thanks in advance.


Is the controller of the subview a UIViewController? You're not supposed to embed a view controller in another one. From the Apple docs:

You should not use multiple custom view controllers to manage different portions of the same view hierarchy. Similarly, you should not use a single custom view controller object to manage multiple screens worth of content. http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/AboutViewControllers/AboutViewControllers.html#//apple_ref/doc/uid/TP40007457-CH112-SW12

You could set the autoresize mask on the subviews.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜