【问题标题】:Is having a UIPickerView in a UIActionSheet acceptable?在 UIActionSheet 中有 UIPickerView 是否可以接受?
【发布时间】:2012-02-14 21:14:46
【问题描述】:

在 UIActionSheet 中有一个 UIPickerView 是否可以接受(也就是 Apple 认为可以接受)?

【问题讨论】:

    标签: ios cocoa-touch app-store uipickerview uiactionsheet


    【解决方案1】:

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

    示例代码:HERE 由 Erica Sadun 在她的《iPhone Developer's cookbook》一书中编写。第11章秘方21

    【讨论】:

    • 不,但她设置代码的方式是相当开放的抽象。了解什么控制什么,你应该准备好滚动
    【解决方案2】:

    是的。可以接受。

    设置 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];
    

    【讨论】:

      【解决方案3】:

      应该这样做:

      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 。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-12-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-23
        • 2012-10-03
        • 1970-01-01
        相关资源
        最近更新 更多