小编Pet*_*ter的帖子

iOS 6横向和纵向

我有一个表格,里面有一个来自plist文件的大量列表,点击每个文件会带你到一个新的视图,一个xib.

我在.xib中有2个视图,一个用于纵向,一个用于横向

在我的文件中我有这个:

IBOutlet UIView *portraitView;  
IBOutlet UIView *landscapeView;

@property (nonatomic, retain) IBOutlet UIView *portraitView;  
@property (nonatomic, retain) IBOutlet UIView *landscapeView;
Run Code Online (Sandbox Code Playgroud)

在我的m文件中:

[super viewDidLoad];  
    // Do any additional setup after loading the view from its nib.

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];

}

- (void) orientationChanged:(id)object
{
    UIInterfaceOrientation interfaceOrientation = [[object object] orientation];

if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)  
    {  
        self.view = self.portraitView;  
    }  
    else
    {  
        self.view = self.landscapeView;  
    }  
}

- (void)viewDidUnload
{

    [super …
Run Code Online (Sandbox Code Playgroud)

device-orientation ios6 xcode4.5

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

device-orientation ×1

ios6 ×1

xcode4.5 ×1