旋转设备时如何更换新笔尖?

DNB*_*ims 6 iphone objective-c

我有一个helloController,它是一个UIViewController,如果我旋转设备,我希望它改变它来加载一个新的笔尖"helloHorizo​​ntal.xib",我该怎么办?谢谢.

小智 1

你可以这样,(我手边没有xcode,所以这个代码可能不完全准确)

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if((interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)){
WhatYourNewViewClassISCAlled* newView = [[WhatYourNewViewClassISCAlled alloc] initWithNibName:@"NIBNAME" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:newView animated:YES];
}
Run Code Online (Sandbox Code Playgroud)