【问题标题】:Remove Padding from UIActionSheet Popover从 UIActionSheet 弹出框删除填充
【发布时间】:2014-01-21 08:15:22
【问题描述】:

我正在创建 UIActionSheet 以允许用户拍摄或选择照片。谁能告诉我为什么它的显示与苹果的不一样?这是针对 iPad 的,所以我没有声明取消按钮。

UIActionSheet *actionSheet = [[UIActionSheet alloc] init];
actionSheet.delegate = self;
[actionSheet addButtonWithTitle:NSLocalizedString(@"choosePhotoPopoverButton", @"Choose Photo - Get a photo from the album.")];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
    [actionSheet addButtonWithTitle:NSLocalizedString(@"takePhotoPopoverButton", @"Take Photo - Use camera to take photo.")];
}
[actionSheet showFromRect:self.imageView.frame inView:self animated:YES];

Apple 的通讯录应用。边距紧缩。行之间的线。

我的工作应用示例。底部有额外的填充物。行与行之间没有线。

感谢您的任何见解。

【问题讨论】:

    标签: ios ipad ios7


    【解决方案1】:

    试试这个

    UIActionSheet *actionSheet;
    
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
        actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate: self cancelButtonTitle:@"" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo",@"Camera", nil];
    }else{
        actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate: self cancelButtonTitle:@"" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", nil];
    }
    
    [actionSheet showFromRect:self.imageView.frame inView:self animated:YES];
    

    【讨论】:

      【解决方案2】:

      您仍然需要声明一个取消按钮。在 iPad 上运行时,它会简单地忽略取消按钮,而在 iPhone 上它会使用它

      【讨论】:

      • 噢!这似乎可以解释它。谢谢。
      【解决方案3】:

      我想保持使用 addButtonWithTitle 的灵活性,但不幸的是,在 iPad 上,它不会在底部按钮上方显示一行。这成功了。如果有取消按钮,iPad 会自动切断最后一个按钮。如果您使用的是 iPad,则不需要取消按钮。

      UIActionSheet *actionSheet = [[UIActionSheet alloc] init];
      actionSheet.delegate = self;
      [actionSheet addButtonWithTitle:NSLocalizedString(@"choosePhotoPopoverButton", @"Choose Photo - Get a photo from the album.")];
      if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
          [actionSheet addButtonWithTitle:NSLocalizedString(@"takePhotoPopoverButton", @"Take Photo - Use camera to take photo.")];
      }
      actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:(@"Cancel");
      [actionSheet showFromRect:self.imageView.frame inView:self animated:YES];
      

      【讨论】:

        猜你喜欢
        • 2017-12-23
        • 1970-01-01
        • 2019-04-20
        • 2022-01-25
        • 2017-10-10
        • 2012-12-27
        • 1970-01-01
        • 2014-04-10
        • 2016-07-26
        相关资源
        最近更新 更多