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(interfaceOrientation == 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 could set the autoresize mask on the subviews.