2012-06-25 27 views
0

我的一個視圖中有一個輕擊識別,在其中我應該從現有的nib文件中顯示一個彈出視圖。我加入以下代碼在Xcode 4中創建一個彈出視圖

FeedTabReplyView *d = [[FeedTabReplyView alloc]initWithNibName:@"FeedTabReplyView" bundle:nil]; 
//d.delegate = self; 
//create popover and put V2 in the popover view 
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:d]; 
//popoverController.delegate = self; //optional 
CGSize size = CGSizeMake(325, 75); 
popoverController.popoverContentSize = size; 
[popoverController presentPopoverFromRect:recognizer.view.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 

但它拋出一個異常:

'NSInvalidArgumentException' 的,理由是: ' - [UIPopoverController initWithContentViewController:當在 UIUserInterfaceIdiomPad沒有運行叫。'

回答

2

UIPopoverController僅適用於iPad的,但是對於iPhone有一個非常好的類WEPopover

它非常容易使用,並且它擁有幾乎所有的UIPopoverController方法和屬性

1

奧馬爾是正確的。

從蘋果DOC:

酥料餅的控制器是隻在iPad設備上使用。試圖在其他設備上創建一個會導致異常。

不使用第三方API,爲什麼不使用UIActionSheet

如果您需要開發基於界面習慣用法的通用應用程序,則可以創建彈出式窗口(iPad)或操作表(iPhone)。

相關問題