Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone iPad上UIActionSheet的问题_Iphone_Ios_Ipad_Uiactionsheet - Fatal编程技术网

Iphone iPad上UIActionSheet的问题

Iphone iPad上UIActionSheet的问题,iphone,ios,ipad,uiactionsheet,Iphone,Ios,Ipad,Uiactionsheet,我正在制作一个与iPhone和iPad兼容的应用程序,并在操作表中显示一个选择器,如下所示: actionSheet = [[UIActionSheet alloc] initWithTitle:@"Day / Month" delegate:self cancelButtonTitle:nil

我正在制作一个与iPhone和iPad兼容的应用程序,并在操作表中显示一个选择器,如下所示:

actionSheet = [[UIActionSheet alloc] initWithTitle:@"Day / Month"
                                          delegate:self
                                 cancelButtonTitle:nil
                            destructiveButtonTitle:nil
                                 otherButtonTitles:nil];

picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0,40,0,0)];
picker.delegate = self;
picker.showsSelectionIndicator = YES;
[actionSheet addSubview:picker];

[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
[actionSheet setBounds:CGRectMake(0,0,320,469)];
这对iPhone很有效,但对于代码相同的iPad版本,撇开不同维度的代码不谈,会产生以下错误:

*由于未捕获异常而终止应用程序 'NSInternalInconsistencyException',原因:'无效参数不存在 满意:查看!=零

在这一行:

[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
我试过showInView:self.view,self.Window,self.view.superview,但什么都没有


我想知道是什么导致了这个错误,不会让我以同样的方式去做。。。提前谢谢

一张行动单在iPad上被转换成一个弹出窗口。有两种方法可以显示弹出窗口-

 - (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view
 permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
 animated:(BOOL)animated;

 - (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item
 permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
 animated:(BOOL)animated;
根据这一猜测,我认为您可以尝试使用以下方法之一来展示行动表-

- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated 
- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated
而不是使用
showInView: