Objective c NSInvalidArgumentException错误。未在UIUserInterfaceIdiomPad下运行

Objective c NSInvalidArgumentException错误。未在UIUserInterfaceIdiomPad下运行,objective-c,ios,xcode,universal,Objective C,Ios,Xcode,Universal,虽然我明白我为什么会收到一个错误 '',原因:'-[UIPopoverController initWithContentViewController:]在未在UIUserInterfaceIdiomPad下运行时调用。' 纠正它变得有点棘手。我的弹出窗口仅在ipad上需要,而在iphone版本上不需要。我省略了iPhone的任何代码if语句,但仍然发生了故障。假设我必须调用iphone上的视图以及它的通用应用程序,我只是在if-iphone语句中调用了nib,但这也不起作用 - (IBAct

虽然我明白我为什么会收到一个错误

'',原因:'-[UIPopoverController initWithContentViewController:]在未在UIUserInterfaceIdiomPad下运行时调用。'

纠正它变得有点棘手。我的弹出窗口仅在ipad上需要,而在iphone版本上不需要。我省略了iPhone的任何代码
if语句
,但仍然发生了故障。假设我必须调用iphone上的视图以及它的通用应用程序,我只是在
if-iphone语句中调用了nib,但这也不起作用

 - (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];



}
即使im使用
if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad){

流行音乐的创作

.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];

您的错误消息显示您试图实例化一个popover。代码仅用于演示它。您还需要处理该实例化。

如果尝试记录当前设备习惯用法,您会看到什么?它应该是[self-presentModalViewController:pop animated:YES]@Moxy,我虽然这样想,但我得到了一个无
@界面错误
其他东西在声明
当前模式视图动画
在什么类中实现-popZs:?什么类是
zsTablePop
的子类?请你扩展一下好吗?这个弹出窗口在iPad上工作正常,错误发生在iphone上,Im我不知道它想要什么。我知道我可以在iphone上展示一个popover,所以我想加载nib就可以了,但它仍然说
没有在UIUserInterfaceIdiomPad下运行
popover是在哪里创建的?它似乎也在iphone上创建的-因此出现了错误。哦,找到你了。我编辑了我的问题代码,显示了popover的创建,什么你认为呢?我不能评论只显示半个方法的代码。该方法在某个地方被调用-可能在这里,可能在其他地方。还要检查你的NIB-如果它们包含UIPovoverController,那也可能是个问题。没有NIB包含弹出式控制器。它是一个UIVIew,该方法的唯一其他代码在.h
-(iAction)popZs:(id)sender;@property(强,非原子)ibuibutton*show;
这就是pop pover整个项目中的所有代码