kar*_*e23 2 iphone uiactionsheet ipad ios
我正在为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)];
Run Code Online (Sandbox Code Playgroud)
这适用于iPhone,但对于具有相同代码的iPad版本,除了那些不同尺寸的人给我以下错误:
*由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'无效的参数不满足:view!= nil'
在这一行:
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
Run Code Online (Sandbox Code Playgroud)
我尝试过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;
Run Code Online (Sandbox Code Playgroud)
从这里猜测,我认为您可以尝试使用以下方法之一来呈现行动表 -
- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated
- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated
Run Code Online (Sandbox Code Playgroud)
而不是使用showInView:
.
归档时间: |
|
查看次数: |
3844 次 |
最近记录: |