ios – UIDeviceOrientation ipad

前端之家收集整理的这篇文章主要介绍了ios – UIDeviceOrientation ipad前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有以下代码根据方向填充视图.这总是会返回景观.
- (void)setData:(BCPlaylist *)list  {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown){
      NSLog(@"portrait");
      [self setPlaylist:list];
      [self renderPlaylist];
      [activity stopAnimating];
    }else{
      NSLog(@"landscape");
      [self setPlaylist:list];
      [self renderPlaylistOne];
      [activity stopAnimating];
     }
}

我正确地改变了视图 – (void)animateRotation:(UIInterfaceOrientation)interfaceOrientation
持续时间:(NSTimeInterval)持续时间{
但是在更改播放列表时已经在横向或纵向中不起作用.

解决方法

而不是使用[[UIDevice currentDevice] orientation]来检查方向,使用状态栏方向来获得精确的方向.
UIDeviceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
原文链接:https://www.f2er.com/iOS/328957.html

猜你在找的iOS相关文章