日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

设置ios6中UIViewController旋转

發(fā)布時間:2024/4/15 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 设置ios6中UIViewController旋转 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?1、首先在appDelegate中,把view添加到window中有兩種方式、

?

?

?

[cpp]view plaincopyprint?

?

  • self.window.rootViewController = self.view;
  • [self.window addSubview:self.view.view];
  • ?

    但是如果用第二種的話,在ios6.0中再去設置屏幕旋轉(zhuǎn)是沒有任何效果的,必須使用第一種。在ios6.0以前的版本是沒有這種分別的。

    2、 開啟全部方向屏幕旋轉(zhuǎn)的方式

    iOS6.0之前: 只需這個方法返回yes即可

    ?

    ?

    [cpp]view plaincopyprint?

    ?

  • - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  • {
  • returnYES;
  • }
  • ?

    iOS6.0中 需要這三個方法一起使用才可以

    ?

    ?

    [cpp]view plaincopyprint?

    ?

  • - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  • {
  • return(toInterfaceOrientation != UIInterfaceOrientationMaskPortraitUpsideDown);
  • }
  • - (BOOL)shouldAutorotate
  • {
  • returnYES;
  • }
  • - (NSUInteger)supportedInterfaceOrientations
  • {
  • returnUIInterfaceOrientationMaskAllButUpsideDown;
  • }
  • ?

    當然了關閉全部方向屏幕旋轉(zhuǎn)的方式則把上面的返回值改為no即可

    iOS6.0之前:

    ?

    ?

    [cpp]view plaincopyprint?

    ?

  • - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  • {
  • returnNO;
  • }
  • ?

    iOS6.0

    ?

    ?

    [cpp]view plaincopyprint?

    ?

  • - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  • {
  • return(toInterfaceOrientation == UIInterfaceOrientationPortrait);
  • }
  • - (BOOL)shouldAutorotate
  • {
  • returnNO;
  • }
  • - (NSUInteger)supportedInterfaceOrientations
  • {
  • returnUIInterfaceOrientationMaskPortrait;//只支持這一個方向(正常的方向)
  • }
  • ?

    使用屏幕旋轉(zhuǎn)常用的方法

    ?

    [cpp]view plaincopyprint?

    ?

    ?

  • //視圖旋轉(zhuǎn)之前自動調(diào)用
  • -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
  • NSLog(@"視圖旋轉(zhuǎn)之前自動調(diào)用");
  • }
  • //視圖旋轉(zhuǎn)方向發(fā)生改變時會自動調(diào)用
  • -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
  • {
  • NSLog(@"視圖旋轉(zhuǎn)方向發(fā)生改變時會自動調(diào)用");
  • }
  • //視圖旋轉(zhuǎn)完成之后會自動調(diào)用
  • ?
  • -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
  • NSLog(@"視圖旋轉(zhuǎn)完成之后自動調(diào)用");
  • }
  • 轉(zhuǎn)載于:https://blog.51cto.com/zqlicoder1314/1138109

    總結(jié)

    以上是生活随笔為你收集整理的设置ios6中UIViewController旋转的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。