Pad的界面布局好多时候都要做两套------横屏和竖屏,但在界面切换时,该让哪个布局显示就要判断了,有多种方法,我记录下我用的一种,感觉比较方便:
2015-08-12 10:56 marysneaker 阅读(536) 评论(0) 编辑 收藏 举报NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; //Get the notification centre for the app
[nc addObserver:self //Add yourself as an observer
selector:@selector(orientationChanged)
name:UIDeviceOrientationDidChangeNotification
object:nil];//这个函数用来获取当前设备的方向,
- (void)orientationChanged
{
//UIView *ftView = [self.view viewWithTag:200];
if([[UIDevice currentDevice] orientation] ==
UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice]
orientation] == UIDeviceOrientationLandscapeRight)//判断左右
{
//界面的新布局
}
if([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait )//我有个方向不支持,如果想都支持那就不要这个if条件就行了
{
//界面的新布局
}
}