UIPickerView 在 UIActionSheet 中可以接受吗?

发布于 2025-01-05 07:57:35 字数 64 浏览 1 评论 0原文

在 UIActionSheet 中包含 UIPickerView 是否可以接受(又名 Apple 认为可以接受)?

Is it acceptable (aka would Apple consider it acceptable) to have a UIPickerView in a UIActionSheet?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

撩动你心 2025-01-12 07:57:35

是的,这是完全可以接受的。在某种程度上,它甚至受到鼓励。

示例代码: 此处作者:Erica Sadun,在她的《iPhone 开发者食谱》一书中。第11章 食谱21

Yes, It is totally acceptable. To some degree its even encouraged.

Example code: HERE by Erica Sadun in her book iPhone Developer's cookbook. Chapter 11 Recipe 21

一杆小烟枪 2025-01-12 07:57:35

是的。这是可以接受的。

设置 UIPickerView 的框架

将 UIPickerView 添加到 actionView

我记得,在这种情况下,actionView 将全屏

UIActionSheet *actionView = [[UIActionSheet alloc] initWith...];
UIPickerView *pickerView = [UIPickerView alloc] init...];
pickerView.frame = CGRect(....);
[actionView addSubview:pickerView];
[pickerView release];
[actionView showInView:theView]; 
[actionView release];

Yes. It is acceptable.

set the frame of the UIPickerView

add the UIPickerView to the actionView

As I remember, actionView will be full screen in this case

UIActionSheet *actionView = [[UIActionSheet alloc] initWith...];
UIPickerView *pickerView = [UIPickerView alloc] init...];
pickerView.frame = CGRect(....);
[actionView addSubview:pickerView];
[pickerView release];
[actionView showInView:theView]; 
[actionView release];
凶凌 2025-01-12 07:57:35

这应该可以做到:

NSString *title = @"\n\n\n\n\n\n\n\n\n\n\n\n"; // <--- Taken from Erica Sadun´s CookBook
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles: nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[actionSheet setBounds:CGRectMake(0,0,320,485)];
UIPickerView *picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 216)];
[picker setDataSource:self];
[picker setDelegate:self];
[picker setShowsSelectionIndicator:YES];
[actionSheet addSubview:picker];
[actionSheet showFromTabBar:[[self tabBarController] tabBar]];

请记住,您必须设置 UIPickerView 的 dataSource 和 delegate 。

This should do it :

NSString *title = @"\n\n\n\n\n\n\n\n\n\n\n\n"; // <--- Taken from Erica Sadun´s CookBook
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles: nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[actionSheet setBounds:CGRectMake(0,0,320,485)];
UIPickerView *picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 216)];
[picker setDataSource:self];
[picker setDelegate:self];
[picker setShowsSelectionIndicator:YES];
[actionSheet addSubview:picker];
[actionSheet showFromTabBar:[[self tabBarController] tabBar]];

Please remember that you have to set UIPickerView´s dataSource and delegate .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文