2012-10-04 40 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

相关问题