ios屏幕旋转注意事项

下面是一些代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;

//返回yes表示支持屏幕的旋转哦,如果为no,你的view将不会跟随屏幕旋转

}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {  

//屏幕将要转到时执行
    if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {  //如果是模向时执行啥事件
        // 重新加载一个Nib文件 
        //[[NSBundle mainBundle] loadNibNamed:@"LoginViewLandscape" owner:self options:nil]; 
        NSLog(@"cccccccccccccccccccc");   
       
       
    }else {  

//如果是纵向时执行啥事件
        // 重新加载一个Nib文件 
        // [[NSBundle mainBundle] loadNibNamed:@"LoginView" owner:self options:nil]; 
        NSLog(@"kkkkkkkkkkkkkkkkkkkkk");   
       
       
    } 
}

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{    //屏幕转动结束后触发,跟上面的差不多,也可以调用这个
    if(fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
    {  //如果向左方向,显示提示框
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"弹窗"
                                                       message:@"左横屏"
                                                      delegate:self
                                             cancelButtonTitle:@"关闭"
                                             otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
}


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值