1.UISplitViewController
2.判断是iPad
if
(
UI_USER_INTERFACE_IDIOM
()
==
UIUserInterfaceIdiomPad
)
{
NSLog ( @ " iPad " ) ;
}
else
{
NSLog ( @ " iPhone " ) ;
}
iPad自带兼容模式可以运行iPhone程序。
3.模态视图
(1)使用presentModalViewController,并选择设置modalPresentationStyle属性:
viewController.modalPresentationStyle=UIModalPresentationFormSheet; //样式风格
viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;//动画方向
[self presentModalViewController:viewController animated:YES];// "self" here is a ViewController instance
其中UIModalPresentationStyle包含了多种样式弹出:
UIModalPresentationFullScreen,
UIModalPresentationPageSheet,
UIModalPresentationFormSheet,
UIModalPresentationCurrentContext
(2)使用UIPopoverController
iPhone上没有popover功能
4.中文环境
Localization native development region 改为 China
选择xib,在右侧的Localization中添加Chinese(zh-Hans)
5.直接被添加到window中的view所在的viewController,可以得到旋转事件通知;
独立的view被添加到window中,不会被旋转,可以通过 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationWillChange:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
- (void) orientationWillChange:(NSNotification *) notification {
NSDictionary *userInfo = [notification userInfo];
NSNumber *v = [userInfo objectForKey:UIApplicationStatusBarOrientationUserInfoKey];
UIInterfaceOrientation o = [v intValue];
CGFloat degrees = 0;
if(o == UIInterfaceOrientationLandscapeLeft ) degrees = -90;
else if(o == UIInterfaceOrientationLandscapeRight ) degrees = 90;
else if(o == UIInterfaceOrientationPortraitUpsideDown) degrees = 180;
[UIView beginAnimations:nil context:nil];
alertView.transform = CGAffineTransformMakeRotation(degrees * M_PI / 180);
alertView.frame = CGRectMake((int)alertView.frame.origin.x, (int)alertView.frame.origin.y, (int)alertView.frame.size.width, (int)alertView.frame.size.height);
[UIView commitAnimations];
}
来处理它旋转一个角度;
6.自动旋转
在info.plist中添加 Supported interface orientations (iPad):Landscape (left home button) 这样就只支持左横屏启动,然后用代码控制,在ios5中可以实现系统启动及启动页面固定左横屏,其它页面可以自由横屏。
但在ios6中全部都不能转了。如果 Supported interface orientations (iPad)不写,或四个方向都写全了,才能自由横屏。
7.
{
NSLog ( @ " iPad " ) ;
}
else
{
NSLog ( @ " iPhone " ) ;
}
iPad自带兼容模式可以运行iPhone程序。
3.模态视图
(1)使用presentModalViewController,并选择设置modalPresentationStyle属性:
viewController.modalPresentationStyle=UIModalPresentationFormSheet; //样式风格
viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;//动画方向
[self presentModalViewController:viewController animated:YES];// "self" here is a ViewController instance
其中UIModalPresentationStyle包含了多种样式弹出:
UIModalPresentationFullScreen,
UIModalPresentationPageSheet,
UIModalPresentationFormSheet,
UIModalPresentationCurrentContext
(2)使用UIPopoverController
iPhone上没有popover功能
4.中文环境
Localization native development region 改为 China
选择xib,在右侧的Localization中添加Chinese(zh-Hans)
5.直接被添加到window中的view所在的viewController,可以得到旋转事件通知;
独立的view被添加到window中,不会被旋转,可以通过 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationWillChange:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
- (void) orientationWillChange:(NSNotification *) notification {
NSDictionary *userInfo = [notification userInfo];
NSNumber *v = [userInfo objectForKey:UIApplicationStatusBarOrientationUserInfoKey];
UIInterfaceOrientation o = [v intValue];
CGFloat degrees = 0;
if(o == UIInterfaceOrientationLandscapeLeft ) degrees = -90;
else if(o == UIInterfaceOrientationLandscapeRight ) degrees = 90;
else if(o == UIInterfaceOrientationPortraitUpsideDown) degrees = 180;
[UIView beginAnimations:nil context:nil];
alertView.transform = CGAffineTransformMakeRotation(degrees * M_PI / 180);
alertView.frame = CGRectMake((int)alertView.frame.origin.x, (int)alertView.frame.origin.y, (int)alertView.frame.size.width, (int)alertView.frame.size.height);
[UIView commitAnimations];
}
来处理它旋转一个角度;
6.自动旋转
在info.plist中添加 Supported interface orientations (iPad):Landscape (left home button) 这样就只支持左横屏启动,然后用代码控制,在ios5中可以实现系统启动及启动页面固定左横屏,其它页面可以自由横屏。
但在ios6中全部都不能转了。如果 Supported interface orientations (iPad)不写,或四个方向都写全了,才能自由横屏。
7.