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条件就行了
{
//界面的新布局
}
}