2012-10-04 41 views
0

下沒有運行雖然我明白了爲什麼IM接收到錯誤NSInvalidArgumentException錯誤。 UIUserInterfaceIdiomPad

',原因是:「 - [UIPopoverController initWithContentViewController:]調用時UIUserInterfaceIdiomPad下不運行」

整頓它變得有點棘手。我的彈出窗口只需要在ipad上,而不是在iphone版本上。我省略了iphones if statement的任何代碼,但仍然崩潰。 。假設我必須調用iphone上的視圖以及其通用應用程序,我只需在if iphone statement中調用該筆尖即可,而且這也不起作用。

- (IBAction)popZs:(id)sender { 




if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 

    if ([popoverController isPopoverVisible]) { 
     [popoverController dismissPopoverAnimated:YES]; 
    } else { 

     [self->popoverController setPopoverContentSize: CGSizeMake(601, 571)]; 

     [popoverController presentPopoverFromRect:((UIButton *)sender).bounds 
              inView:sender 
         permittedArrowDirections:UIPopoverArrowDirectionUp 
             animated:YES]; 

    } 



} 
else { 

    /////using iPhone/////not sure how to handle this spart 
    zsTablePop *pop = [[zsTablePop alloc] init]; 
    pop.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
    [pop presentModalViewController:pop animated:YES]; 



} 

不斷得到即使使用if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {

創造流行的IM一樣erorr超過

.m 


#import "ICCircuitDetails.h" 
#import "zsTablePop.h" ///////////////pop over xib///// 

@interface ICCircuitDetails() 



{ 
zsTablePop *controller; 
UIPopoverController *popoverController; 
} 


///////more code///////////// 


- (id)initWithCircuit:(Circuit *)circuit 
{ 


self = [super initWithCertificate:circuit.distributionBoard.certificate]; 
if (self) { 
    self.circuit = circuit; 
    [[NSBundle mainBundle] loadNibNamed:@"ICCircuitDetails" owner:self options:nil]; 
    self.view.contentSize = CGSizeMake(self.contentView.frame.size.width, self.contentView.frame.size.height); 

///////////other code here///////////////// 

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) 

    controller = [[zsTablePop alloc] initWithNibName:@"zsTablePop" bundle:nil]; 
    popoverController = [[UIPopoverController alloc] initWithContentViewController:controller]; 
+0

如果您嘗試記錄當前設備成語,您會看到什麼? – shortstuffsushi

+0

它應該是[self presentModalViewController:pop animated:YES]; – Moxy

+0

@Moxy,我雖然那樣,但我得到了一個沒有'@界面錯誤'別的是聲明'現在的模態視圖動畫' – JSA986

回答

1

你的錯誤消息指出您嘗試實例化一個酥料餅。代碼只是關於展示它。你也需要處理實例化。

+0

請問您可以擴展它嗎?彈出在iPad上正常工作,錯誤發生時,它在iPhone上運行,我不知道它想要什麼。我知道我可以在iPhone上展示彈出窗口,所以認爲加載筆尖會做,但它仍然說'不在UIUserInterfaceIdiomPad下運行' – JSA986

+0

彈出窗口創建在哪裏?它似乎也是在iPhone上創建的 - 因此錯誤。 – Eiko

+0

哦,你了。我編輯了我的問題代碼,顯示流行音樂的創作,您怎麼看? – JSA986

相關問題