【发布时间】:2011-12-19 22:37:10
【问题描述】:
我试图在 iPad 上显示一个 UIActionSheet 并在其中显示一个 UIPickerView,我有适用于 iPhone 的等效代码,所以我的 UIPickerView 委托和数据源的东西可以工作,但是当我使用 @ 时在 iPad 上987654324@ 结果UIPopover/UIActionSheet 太小了,我似乎无法设置框架大小,也没有显示任何按钮。
我不知道这是因为它们超出了界限还是发生了其他事情。这是我删除所有非必要代码(iPhone 等)后代码的样子。有谁知道我做错了什么,有没有人知道任何例子。
CGRect thePickerFrame = CGRectMake(0, 0, 320.0, 485.0);
UIPickerView * thePickerView = [[UIPickerView alloc] initWithFrame:thePickerFrame];
[pickerActionSheet release], pickerActionSheet =
[[UIActionSheet alloc] initWithTitle:@"Choose" delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Next", nil];
thePickerView.showsSelectionIndicator = YES;
thePickerView.dataSource = self;
thePickerView.delegate = self;
[pickerActionSheet addSubview:thePickerView];
[thePickerView selectRow:0 inComponent:0 animated:NO];
[thePickerView release];
[pickerActionSheet showFromRect:currentTextField.bounds
inView:currentTextField animated:NO];
pickerActionSheet.frame = thePickerFrame;
【问题讨论】:
-
我只是做了一些实验,看看何时调用 - [UIActionSheet setFrame:]。我似乎在上面被称为另一个由 iOS 发起的事件循环的事件循环之后 - [UIActionSheet setFrame:] 被调用并显示的小框架。
-
使用此功能在 iPad 上使用 popover 不是更好吗? AFAIK ActionSheet 仅适用于按钮。
标签: objective-c ios cocoa-touch ipad