UIPopoverPresentationController使用

從iOS 8開(kāi)始,蘋(píng)果提出新的 UIPopoverPresentationController代替UIPopoverController。代碼如下:

//創(chuàng)建你需要顯示的controller
UIViewController *cityAlertViewController = [[UIViewController alloc] init]; 
//這里自定義的view
DLpopupView *popupView = [[DLpopupView alloc] initWithFrame:CGRectMake(0.0, 0.0, 
[300, 91) andRestorationName:@“DCpopupView”]; 

cityAlertViewController.view = popupView; 
//設(shè)置modal類(lèi)型
cityAlertViewController.modalPresentationStyle = UIModalPresentationPopover; cityAlertViewController.preferredContentSize = CGSizeMake(300, 91); 
//配置 UIPopoverPresentationController 
UIPopoverPresentationController *cityErrorPopover = cityAlertViewController.popoverPresentationController; 
//設(shè)置代理
cityErrorPopover.delegate = self;
//設(shè)置相關(guān)屬性
  cityErrorPopover.sourceView = self.view;
cityErrorPopover.sourceRect = button.frame; cityErrorPopover.permittedArrowDirections = 
UIPopoverArrowDirectionUp; cityErrorPopover.backgroundColor = greenNormal;
// pop跳轉(zhuǎn)
[self presentViewController:cityAlertViewController animated:YES completion:nil];
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1. 人若沒(méi)有夢(mèng)想,不如死去?!?史蒂芬?霍金 2 要為靈魂找一個(gè)美麗的歸宿,不要為肉體找一塊豪華的墳?zāi)埂?3 只...
    能照閱讀 1,022評(píng)論 0 0
  • 鵜鶘總經(jīng)理:霍勒迪現(xiàn)在最重要的身份是丈夫 摘要:戴維斯和龐德塞特還有幾名鵜鶘隊(duì)員到霍勒迪家里看望他,和他一起訓(xùn)練。...
    prudenceli閱讀 205評(píng)論 0 0
  • iOS開(kāi)發(fā)中我們會(huì)遇到程序拋出異常退出的情況,如果是在調(diào)試的過(guò)程中,異常的信息是一目了然,我們可以很快的定位異常的...
    清晨十分的陽(yáng)光閱讀 4,046評(píng)論 16 44
  • 欲識(shí)金銀氣,多從黃白游。 一生癡絕處,無(wú)夢(mèng)到徽州。 ...
    一個(gè)王大可閱讀 1,544評(píng)論 22 19

友情鏈接更多精彩內(nèi)容