iPad开发简单介绍

  • iPad开发最大的不同在于iPhone的就是屏幕控件的适配,以及横竖屏的旋转。
  • Storyboard中得SizeClass的横竖屏配置,也不支持iPad开发。

1.在控制器中得到设备的旋转方向

在 iOS8及以后,屏幕就只有旋转后屏幕尺寸之分,不再是过期的旋转方向。

  • 在iOS7及以前得到屏幕旋转方向的方法
/**
// UIInterfaceOrientation ,屏幕方向
UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown,
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
*/
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
// 即将旋转执行动画
NSLog(@"%s", __func__);
} - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
// 即将旋转
NSLog(@"%s", __func__);
}
  • 在iOS8以后,屏幕就只有屏幕之分,即当屏幕的宽大于高就是横屏,否则是竖屏。

    • iPad屏幕只有 (1024 * 768)横屏
    • (768 * 1024)竖屏
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
// 1.判断是否是横屏
BOOL isLandscape = size.width == 1024; // 2.设置Dock的宽度和高度
// 获取屏幕旋转动画执行的时间
CGFloat duration = [coordinator transitionDuration];
[UIView animateWithDuration:duration animations:^{ }];
}

2.iPad中Modal弹出控制器的方式和样式

Modal常见有4种呈现样式

控制器属性 modalPresentationStyle
  • UIModalPresentationFullScreen :全屏显示(默认)

  • UIModalPresentationPageSheet

    • 宽度:竖屏时的宽度(768)
    • 高度:当前屏幕的高度(填充整个高度)
  • 横屏

  • 竖屏

  • UIModalPresentationFormSheet :占据屏幕中间的一小块

  • 横屏

  • 竖屏

  • UIModalPresentationCurrentContext :跟随父控制器的呈现样式

Modal一共4种过渡样式

控制器属性 modalTransitionStyle
  • UIModalTransitionStyleCoverVertical :从底部往上钻(默认)
  • UIModalTransitionStyleFlipHorizontal :三维翻转
  • UIModalTransitionStyleCrossDissolve :淡入淡出
  • UIModalTransitionStylePartialCurl :翻页(只显示部分,使用前提:呈现样式必须是UIModalPresentationFullScreen)
  • UIModalPresentationCustom
  • UIModalPresentationOverFullScreen
  • UIModalPresentationOverCurrentContext
  • UIModalPresentationPopover //iOS8之后过渡样式pop样式
  • UIModalPresentationNone

3. iPad特有的UIPopoverController的使用

案例:

情景① 在导航栏上添加leftBarButtonItem按钮,然后弹出UIPopoverController

  • 创建UIPopoverController控制器的内容控制器添加到UIPopoverController上
1>设置内容控制器(并需先创建内容控制器)
  • 强调UIPopoverController不是继承UIViewController,也就不具备显示功能,要设置内容,使用initWithContentViewController设置内容
- (id)initWithContentViewController:(UIViewController *)viewController;

- (void)setContentViewController:(UIViewController *)viewController animated:(BOOL)animated;

@property (nonatomic, retain) UIViewController *contentViewController;
2>设置尺寸
  • 设置popView的大小(默认控制器有多大就显示多大)(120, 44 * 3)

    • UIPopoverController的方法popoverContentSize
    • 内容控制器中设置的方法
      • self.preferredContentSize
      • self.contentSizeForViewInPopover /ios7过时/
3>设置在什么地方显示
  • 调用方法
/**
* 弹出UIPopoverController的方法(一)
*
* @param item 围绕着哪个UIBarButtonItem显示
* @param arrowDirections 箭头的方向
* @param animated 是否通过动画显示出来
*/
- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;

情景② 在导航控制器的View上添加个按钮,点击,弹出一个UIPopoverController控制器,然后这个控制器再用导航控制器包装,显示二级控制器

  • 1>调用方法
/**
* 弹出UIPopoverController
*
* @param rect 指定箭头所指区域的矩形框范围(位置和尺寸)
* @param view rect参数是以view的左上角为坐标原点(0,0)
* @param arrowDirections 箭头的方向
* @param animated 是否通过动画显示出来
*/
- (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;
  • 2>控制器内,有自己的逻辑结构(和正常控制器一样可以跳转返回等)

UIPopoverController消失,

  • 方法
[Popover dismissPopoverAnimated:YES]

4.iPad特有的UISplitViewController的使用

a.masterViewController

  • 1>masterViewController(主要控制器)
  • 2>负责展示主要的菜单内容

b.detailViewController

  • 1>detailViewController(详情控制器)
  • 2>负责展示详细内容

iOS---iPad开发及iPad特有的特技的更多相关文章

  1. iOS开发——高级篇——iPad开发、iPad开发中的modal

    一.iPad简介 1.什么是iPad一款苹果公司于2010年发布的平板电脑定位介于苹果的智能手机iPhone和笔记本电脑产品之间跟iPhone一样,搭载的是iOS操作系统 2.iPhone和iPadi ...

  2. iPad开发(相对于iPhone开发时专有的API)

    iPad开发 一.iPad开发简介 1.什么是iPad 一款苹果公司于2010年发布的平板电脑 定价介于苹果的智能手机iPhone和笔记本电脑产品之间 跟iPhone一样,搭载的是iOS操作系统 2. ...

  3. iOS - 初学iPad开发入门

    iPad是一款苹果公司于2010年发布的平板电脑定位介于苹果的智能手机iPhone和笔记本电脑MacBook产品之间跟iPhone一样,搭载的是iOS操作系统 iPhone和iPad开发的区别 屏幕的 ...

  4. iOS开发UI篇—iPad开发中得modal介绍

    iOS开发UI篇—iPad开发中得modal介绍 一.简单介绍 说明1: 在iPhone开发中,Modal是一种常见的切换控制器的方式 默认是从屏幕底部往上弹出,直到完全盖住后面的内容为止 说明2: ...

  5. 《疯狂iOS讲义(下)——iPhone/iPad高级应用与手游开发(含CD光盘1张)》

    <疯狂iOS讲义(下)——iPhone/iPad高级应用与手游开发(含CD光盘1张)> 基本信息 作者: 李刚    肖文吉 出版社:电子工业出版社 ISBN:9787121224379 ...

  6. iOS(iPhone,iPad))开发(Objective-C)开发库常用库索引

    http://www.code4app.com 这网站不错,收集各种 iOS App 开发可以用到的代码示例  http://www.cocoacontrols.com/ 英文版本的lib收集  ht ...

  7. 初学iPad开发入门

    iPad是一款苹果公司于2010年发布的平板电脑定位介于苹果的智能手机iPhone和笔记本电脑MacBook产品之间跟iPhone一样,搭载的是iOS操作系统 iPhone和iPad开发的区别 屏幕的 ...

  8. iPad开发中UIPopoverController的使用

    什么是UIPopoverController 是iPad开发中常见的一种控制器 跟其他控制器不一样的是,它直接继承自NSObject,并非继承自UIViewController 它只占用部分屏幕空间来 ...

  9. JS判断客户端是否是iOS或者Android或者ipad(三)

     *  * @function: 判断浏览器类型是否是Safari.Firefox.ie.chrome浏览器  * @return: true或false  *  */ function isSafa ...

随机推荐

  1. jquery源码学习笔记二:jQuery工厂

    笔记一里记录,jQuery的总体结构如下: (function( global, factory ) { //调用factory(工厂)生成jQuery实例 factory( global ); }( ...

  2. 【bzoj2462】[BeiJing2011]矩阵模板

    #include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> # ...

  3. Mac下安装manen

    下载好maven,放到特定目录下: 打开终端: 进入根目录: cd ~ 创建文件.bash_profile: vi .bash_profile 编辑文件添加内容 MAVEN_HOME=/Users/c ...

  4. Difference between HttpContext.Request and Request

    https://stackoverflow.com/questions/5547989/difference-between-httpcontext-request-and-request Well: ...

  5. YTU 2402: Common Subsequence

    2402: Common Subsequence 时间限制: 1 Sec  内存限制: 32 MB 提交: 63  解决: 33 题目描述 A subsequence of a given seque ...

  6. YTU 2586: 填空题B-字画鉴别

    2586: 填空题B-字画鉴别 时间限制: 1 Sec  内存限制: 128 MB 提交: 509  解决: 131 题目描述 注:本题只需要提交填写部分的代码,请按照C语言方式提交. 古玩店老板小勇 ...

  7. YTU 2851: 数字游戏

    2851: 数字游戏 时间限制: 1 Sec  内存限制: 128 MB 提交: 164  解决: 85 题目描述 输入若干个正整数,将其中能写成其它两个正整数的平方和的数输出来. 例,若输入的数中有 ...

  8. YTU 1098: The 3n + 1 problem

    1098: The 3n + 1 problem 时间限制: 1 Sec  内存限制: 64 MB 提交: 368  解决: 148 题目描述 Consider the following algor ...

  9. 【TJOI 2014】 上升子序列

    [题目链接] 点击打开链接 [算法] 先考虑50分的做法 : f[i]表示以i结尾的本质不同的上升子序列的个数 则f[i] = sigma(f[j]) (j < i,a[j] < a[i] ...

  10. 第十八周 Leetcode 72. Edit Distance(HARD) O(N^2)DP

    Leetcode72 看起来比较棘手的一道题(列DP方程还是要大胆猜想..) DP方程该怎么列呢? dp[i][j]表示字符串a[0....i-1]转化为b[0....j-1]的最少距离 转移方程分三 ...