网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

IOS学习之响应设备的横竖屏状态,旋转界面达到横竖屏效果-创新互联

监听 UIDeviceOrientationDidChangeNotification的广播,再根据[[UIDevice currentDevice] orientation]获取到屏幕的方向。

创新互联从2013年创立,先为银川等服务建站,银川等地企业,进行企业商务咨询服务。为银川企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
-(void) viewDidLoad {
     // Request to turn on accelerometer and begin receiving accelerometer events
     [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
 
- (void)orientationChanged:(NSNotification *)notification {
     // 获取当前屏幕方向interfaceOrientation
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (orientation == UIDeviceOrientationLandscapeLeft) {// 左横屏
        [self allPlay];
    } else {// 其他的都是正竖屏
        [self normalPlay];
    }
}
 
-(void) viewDidDisappear {
     // Request to stop receiving accelerometer events and turn off accelerometer
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
}
- (void) allPlay {
    // 按钮
    [self.allScreenPlayBtn setHidden:YES];
    [self.normalPlayBtn setHidden:NO];
    // 状态栏
    isStatusBaeHidden = YES;
    [self prefersStatusBarHidden];    // 是否隐藏状态栏
    // 导航栏
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    // view旋转
    [UIView beginAnimations:@"rotate" context:nil];
    [UIView setAnimationDuration:0.6f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    self.cbPlayer.view.transform = CGAffineTransformRotate(self.view.transform, M_PI_2);
    self.normalPlayBtn.transform = CGAffineTransformRotate(self.normalPlayBtn.transform, M_PI_2);
    [UIView commitAnimations];
    
    CGSize size = [[UIScreen mainScreen] bounds].size;
    CGRect rect = CGRectMake(0, -20, size.width, size.height);
    [self.cbPlayer.view setFrame:rect];
}
- (void) normalPlay {
    // 按钮
    [self.allScreenPlayBtn setHidden:NO];
    [self.normalPlayBtn setHidden:YES];
    // 状态栏
    isStatusBaeHidden = NO;
    [self prefersStatusBarHidden];
    // 导航栏
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    // view旋转
    [UIView beginAnimations:@"rotate" context:nil];
    [UIView setAnimationDuration:0.6f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    self.cbPlayer.view.transform = CGAffineTransformRotate(self.view.transform, 0);
    self.normalPlayBtn.transform = CGAffineTransformRotate(self.normalPlayBtn.transform, 0);
    [UIView commitAnimations];
    [self.cbPlayer.view setFrame:self.playView.frame];
}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前文章:IOS学习之响应设备的横竖屏状态,旋转界面达到横竖屏效果-创新互联
标题链接:http://bjjierui.cn/article/hjish.html

其他资讯