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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iOS---iPad开发及iPad特有的特技

發(fā)布時間:2024/10/12 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iOS---iPad开发及iPad特有的特技 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

iPad開發(fā)簡單介紹

  • iPad開發(fā)最大的不同在于iPhone的就是屏幕控件的適配,以及橫豎屏的旋轉(zhuǎn)。
  • Storyboard中得SizeClass的橫豎屏配置,也不支持iPad開發(fā)。

1.在控制器中得到設(shè)備的旋轉(zhuǎn)方向

在 iOS8及以后,屏幕就只有旋轉(zhuǎn)后屏幕尺寸之分,不再是過期的旋轉(zhuǎn)方向。

  • 在iOS7及以前得到屏幕旋轉(zhuǎn)方向的方法
/**// UIInterfaceOrientation ,屏幕方向UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown,UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft*/ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {// 即將旋轉(zhuǎn)執(zhí)行動畫NSLog(@"%s", __func__); }- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {// 即將旋轉(zhuǎn)NSLog(@"%s", __func__); }
  • 在iOS8以后,屏幕就只有屏幕之分,即當(dāng)屏幕的寬大于高就是橫屏,否則是豎屏。
    • iPad屏幕只有 (1024 * 768)橫屏
    • (768 * 1024)豎屏
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {// 1.判斷是否是橫屏BOOL isLandscape = size.width == 1024;// 2.設(shè)置Dock的寬度和高度// 獲取屏幕旋轉(zhuǎn)動畫執(zhí)行的時間CGFloat duration = [coordinator transitionDuration];[UIView animateWithDuration:duration animations:^{}]; }

2.iPad中Modal彈出控制器的方式和樣式

Modal常見有4種呈現(xiàn)樣式

控制器屬性 modalPresentationStyle
  • UIModalPresentationFullScreen :全屏顯示(默認(rèn))
  • UIModalPresentationPageSheet
    • 寬度:豎屏?xí)r的寬度(768)
    • 高度:當(dāng)前屏幕的高度(填充整個高度)
  • 橫屏

  • 豎屏

  • UIModalPresentationFormSheet :占據(jù)屏幕中間的一小塊

  • 橫屏

  • 豎屏

  • UIModalPresentationCurrentContext :跟隨父控制器的呈現(xiàn)樣式

Modal一共4種過渡樣式

控制器屬性 modalTransitionStyle
  • UIModalTransitionStyleCoverVertical :從底部往上鉆(默認(rèn))
  • UIModalTransitionStyleFlipHorizontal :三維翻轉(zhuǎn)
  • UIModalTransitionStyleCrossDissolve :淡入淡出
  • UIModalTransitionStylePartialCurl :翻頁(只顯示部分,使用前提:呈現(xiàn)樣式必須是UIModalPresentationFullScreen)
  • UIModalPresentationCustom
  • UIModalPresentationOverFullScreen
  • UIModalPresentationOverCurrentContext
  • UIModalPresentationPopover //iOS8之后過渡樣式pop樣式
  • UIModalPresentationNone

3. iPad特有的UIPopoverController的使用

案例:

情景① 在導(dǎo)航欄上添加leftBarButtonItem按鈕,然后彈出UIPopoverController

  • 創(chuàng)建UIPopoverController控制器的內(nèi)容控制器添加到UIPopoverController上
1>設(shè)置內(nèi)容控制器(并需先創(chuàng)建內(nèi)容控制器)
  • 強調(diào)UIPopoverController不是繼承UIViewController,也就不具備顯示功能,要設(shè)置內(nèi)容,使用initWithContentViewController設(shè)置內(nèi)容
- (id)initWithContentViewController:(UIViewController *)viewController;- (void)setContentViewController:(UIViewController *)viewController animated:(BOOL)animated;@property (nonatomic, retain) UIViewController *contentViewController;
2>設(shè)置尺寸
  • 設(shè)置popView的大小(默認(rèn)控制器有多大就顯示多大)(120, 44 * 3)
    • UIPopoverController的方法popoverContentSize
    • 內(nèi)容控制器中設(shè)置的方法
      • self.preferredContentSize
      • self.contentSizeForViewInPopover /ios7過時/
3>設(shè)置在什么地方顯示
  • 調(diào)用方法
/*** 彈出UIPopoverController的方法(一)** @param item 圍繞著哪個UIBarButtonItem顯示* @param arrowDirections 箭頭的方向* @param animated 是否通過動畫顯示出來*/ - (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;

情景② 在導(dǎo)航控制器的View上添加個按鈕,點擊,彈出一個UIPopoverController控制器,然后這個控制器再用導(dǎo)航控制器包裝,顯示二級控制器

  • 1>調(diào)用方法
/*** 彈出UIPopoverController** @param rect 指定箭頭所指區(qū)域的矩形框范圍(位置和尺寸)* @param view rect參數(shù)是以view的左上角為坐標(biāo)原點(0,0)* @param arrowDirections 箭頭的方向* @param animated 是否通過動畫顯示出來*/ - (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;
  • 2>控制器內(nèi),有自己的邏輯結(jié)構(gòu)(和正常控制器一樣可以跳轉(zhuǎn)返回等)

UIPopoverController消失,

  • 方法
[Popover dismissPopoverAnimated:YES]

4.iPad特有的UISplitViewController的使用

a.masterViewController

  • 1>masterViewController(主要控制器)
  • 2>負(fù)責(zé)展示主要的菜單內(nèi)容

b.detailViewController

  • 1>detailViewController(詳情控制器)
  • 2>負(fù)責(zé)展示詳細(xì)內(nèi)容

轉(zhuǎn)載于:https://www.cnblogs.com/ShaoYinling/p/4790243.html

總結(jié)

以上是生活随笔為你收集整理的iOS---iPad开发及iPad特有的特技的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

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