//聯(lián)系人:石虎QQ: 1224614774昵稱:嗡嘛呢叭咪哄
一、概念
iPhone和iPad開發(fā)的區(qū)別:1.屏幕的尺寸 \\分辨率2.UI元素的排布 \\設(shè)計(jì)3.鍵盤4.API5.屏幕方向的支持
二拢肆、屏幕的尺寸 \分辨率
三.開發(fā)細(xì)節(jié)
1)如何新建一個(gè)iPad應(yīng)用程序
2)設(shè)備支持的應(yīng)用程序
iPhone上只能運(yùn)行iPhone程序
iPad上能夠運(yùn)行iPhone \ iPad程序
3)開發(fā)過程
iPhone和iPad開發(fā)的流程是一致的
在iPhone開發(fā)中用到的所有知識基本都能用在iPad上
四.Modal使用的區(qū)別
在iPhone開發(fā)中粒督,Modal是一種常見的切換控制器的方式窜司,
默認(rèn)是從屏幕底部往上彈出绩蜻,直到完全蓋住后面的內(nèi)容為止厚掷;
而在iPad開發(fā)中礁苗,Modal的使用頻率也是非常高的.
4.1爬凑、對比iPhone開發(fā),Modal在iPad開發(fā)中多了一些用法
1) 呈現(xiàn)樣式
Modal出來的控制器试伙,最終顯示出來的樣子
Modal常見有4種呈現(xiàn)樣式UIModalPresentationFullScreen:全屏顯示(默認(rèn))UIModalPresentationPageSheet:? ? ? ? 寬度:豎屏?xí)r的寬度(768)? ? ? 高度:當(dāng)前屏幕的高度(填充整個(gè)高度)UIModalPresentationFormSheet:占據(jù)屏幕中間的一小塊UIModalPresentationCurrentContext:跟隨父控制器的呈現(xiàn)樣式
2) 過渡樣式
Modal出來的控制器嘁信,是以怎樣的動(dòng)畫呈現(xiàn)出來
Modal一共4種過渡樣式UIModalTransitionStyleCoverVertical:從底部往上鉆(默認(rèn))UIModalTransitionStyleFlipHorizontal:三維翻轉(zhuǎn)UIModalTransitionStyleCrossDissolve:淡入淡出UIModalTransitionStylePartialCurl:翻頁(只顯示部分,使用前提:呈現(xiàn)樣式必須是UIModalPresentationFullScreen)
五.UIPopoverController的使用
5.1疏叨、簡介
UIPopoverController是iPad開發(fā)中常見的一種控制器潘靖,
跟其他控制器不一樣的是,它直接繼承自NSObject考廉,并非繼承自UIViewController秘豹;
它只占用部分屏幕空間來呈現(xiàn)信息,而且顯示在屏幕的最前面
5.2昌粤、使用步驟
要想顯示一個(gè)UIPopoverController既绕,需要經(jīng)過下列三步驟:
1)設(shè)置內(nèi)容控制器:由于UIPopoverController直接繼承自NSObject,不具備可視化的能力涮坐,因此UIPopoverController上面的內(nèi)容必須由另外一個(gè)繼承自UIViewController的控制器來提供凄贩,這個(gè)控制器稱為“內(nèi)容控制器”2)設(shè)置內(nèi)容的尺寸:顯示出來占據(jù)多少屏幕空間3)設(shè)置顯示的位置:從哪個(gè)地方冒出來
1) 設(shè)置內(nèi)容控制器
設(shè)置內(nèi)容控制器有3種方法:在初始化UIPopoverController的時(shí)候傳入一個(gè)內(nèi)容控制器- (id)initWithContentViewController:(UIViewController*)viewController;@property(nonatomic,retain)UIViewController*contentViewController;- (void)setContentViewController:(UIViewController*)viewController animated:(BOOL)animated;以上方法和屬性都是UIPopoverController的
2) 設(shè)置內(nèi)容的尺寸
設(shè)置內(nèi)容的尺寸有2種方法:@property(nonatomic)CGSizepopoverContentSize;- (void)setPopoverContentSize:(CGSize)size animated:(BOOL)animated;以上方法和屬性都是UIPopoverController的
3) 設(shè)置顯示的位置
設(shè)置顯示的位置有2種方法:
第一種:圍繞著一個(gè)UIBarButtonItem顯示(箭頭指定那個(gè)UIBarButtonItem)/** *? 彈出UIPopoverController * *@paramitem? ? ? ? ? ? 圍繞著哪個(gè)UIBarButtonItem顯示 *@paramarrowDirections 箭頭的方向 *@paramanimated? ? ? ? 是否通過動(dòng)畫顯示出來 */- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)itempermittedArrowDirections:(UIPopoverArrowDirection)arrowDirectionsanimated:(BOOL)animated;
第二種:圍繞著某一塊特定區(qū)域顯示(箭頭指定那塊特定區(qū)域)/** *? 彈出UIPopoverController * *@paramrect? ? ? ? ? ? 指定箭頭所指區(qū)域的矩形框范圍(位置和尺寸) *@paramview? ? ? ? ? ? rect參數(shù)是以view的左上角為坐標(biāo)原點(diǎn)(0,0) *@paramarrowDirections 箭頭的方向 *@paramanimated? ? ? ? 是否通過動(dòng)畫顯示出來 */- (void)presentPopoverFromRect:(CGRect)rectinView:(UIView *)viewpermittedArrowDirections:(UIPopoverArrowDirection)arrowDirectionsanimated:(BOOL)animated;
舉個(gè)小栗子:
如果想讓箭頭指向某一個(gè)UIView的做法有2種做法袱讹,比如指向一個(gè)button
方法1[popoverpresentPopoverFromRect:button.boundsinView:buttonpermittedArrowDirections:UIPopoverArrowDirectionDownanimated:YES];方法2[popoverpresentPopoverFromRect:button.frameinView:button.superviewpermittedArrowDirections:UIPopoverArrowDirectionDownanimated:YES];
5.3疲扎、通過內(nèi)容控制器設(shè)置內(nèi)容尺寸
內(nèi)容控制器可以自行設(shè)置自己在popover中顯示的尺寸
在iOS7之前@property(nonatomic,readwrite)CGSizecontentSizeForViewInPopover;從iOS7開始@property(nonatomic)CGSizepreferredContentSize;以上屬性都是UIViewController的
5.4、常用屬性
代理對象@property(nonatomic,assign)id delegate;是否可見@property(nonatomic,readonly,getter=isPopoverVisible)BOOLpopoverVisible;箭頭方向@property(nonatomic,readonly)UIPopoverArrowDirectionpopoverArrowDirection;關(guān)閉popover(讓popover消失)- (void)dismissPopoverAnimated:(BOOL)animated;
5.5捷雕、防止點(diǎn)擊UIPopoverController區(qū)域外消失
默認(rèn)情況下:
只要UIPopoverController顯示在屏幕上椒丧,UIPopoverController背后的所有控件默認(rèn)是不能跟用戶進(jìn)行正常交互的;
點(diǎn)擊UIPopoverController區(qū)域外的控件,UIPopoverController默認(rèn)會(huì)消失
要想點(diǎn)擊UIPopoverController區(qū)域外的控件時(shí)不讓UIPopoverController消失救巷,解決辦法是設(shè)置passthroughViews屬性
@property (nonatomic, copy) NSArray *passthroughViews;
這個(gè)屬性是設(shè)置當(dāng)UIPopoverController顯示出來時(shí)壶熏,哪些控件可以繼續(xù)跟用戶進(jìn)行正常交互。這樣的話浦译,點(diǎn)擊區(qū)域外的控件就不會(huì)讓UIPopoverController消失了
5.6棒假、常見報(bào)錯(cuò)
在popover的使用過程中溯职,經(jīng)常會(huì)遇到這個(gè)錯(cuò)誤
-[UIPopoverController dealloc] reached while popover is still visible.
錯(cuò)誤的大體意思是:popover在仍舊可見的時(shí)候被銷毀了(調(diào)用了dealloc)
從錯(cuò)誤可以得出的結(jié)論:
*當(dāng)popover仍舊可見的時(shí)候,不準(zhǔn)銷毀popover對象帽哑!在銷毀popover對象之前谜酒,一定先讓popover消失(不可見)*[popoverdismissPopoverAnimated:YES];
5.7、如何iPhone中實(shí)現(xiàn)popover的效果
UIPopoverController這個(gè)類是只能用在iPad中的
要想在iPhone中實(shí)現(xiàn)popover效果妻枕,必須得自定義view僻族,可以參考
http://code4app.com/ios/Popover-View-in-iPhone/4fa931bd06f6e78d0f000000
http://code4app.com/ios/Popup-Menu/512231ac6803fa9e08000000
六.UISplitViewController的使用
a.MenuViewController
1>masterViewController(主要控制器)
2>負(fù)責(zé)展示主要的菜單內(nèi)容
詳細(xì)內(nèi)容(重點(diǎn))
b.DetailViewController
1>detailViewController(詳情控制器)
2>負(fù)責(zé)展示詳細(xì)內(nèi)容
謝謝!!!