在文件中,
他们使用了 performSegueWithIdentifier:sender:和 dismissViewControllerAnimated:completion:,它们在iOS 5.0及更高版本中可用。
在iOS 4.3中,是否有任何智能方法可以将多个笔尖用于不同的ipad界面方向。
答案 0 :(得分:0)
假设您有一个PortraitViewController和一个LandscapeViewController。
您需要以下内容:
@interface PortraitViewController : UIViewController {
BOOL isShowingLandscapeView;
LandscapeViewController *landscapeViewController;
}
@implementation PortraitViewController
- (void)viewDidLoad
{
[super viewDidLoad];
landscapeMainViewController = [[LandscapeMainViewController alloc] initWithNibName:@"LandscapeMainViewController" bundle:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[landscapeMainViewController release]; landscapeMainViewController = nil;
[super dealloc];
}
- (void)orientationChanged:(NSNotification *)notification
{
[self performSelector:@selector(updateLandscapeView) withObject:nil afterDelay:0];
}
- (void)updateLandscapeView
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
if (UIDeviceOrientationIsLandscape(deviceOrientation) && !isShowingLandscapeView)
{
[self presentModalViewController:landscapeMainViewController animated:YES];
isShowingLandscapeView = YES;
}
else if (deviceOrientation == UIDeviceOrientationPortrait && isShowingLandscapeView)
{
[self dismissModalViewControllerAnimated:YES];
isShowingLandscapeView = NO;
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
@interface LandscapeViewController : UIViewController
@end
@implementation LandscapeViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.wantsFullScreenLayout = YES;
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
}
return self;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
@end
致谢:http://www.edumobile.org/iphone/iphone-programming-tutorials/alternativeviews-in-iphone/