从UIActionSheet Popover中删除填充

时间:2014-01-03 15:44:48

标签: ios ipad ios7

我正在创建一个UIActionSheet,允许用户拍摄或选择照片。有人能告诉我为什么它与Apple的显示效果不一样吗?这适用于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的联系人应用。利润率很低。行之间的行。

enter image description here

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

enter image description here

感谢您的任何见解。

3 个答案:

答案 0 :(得分:3)

试试这个

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

答案 1 :(得分:2)

您仍需要声明取消按钮。在iPad上运行时,它将忽略取消按钮,而在iPhone上它将使用它

答案 2 :(得分:0)

我想保持使用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];