2014-01-03 6 views
3

Я создаю таблицу UIActionSheet, чтобы пользователи могли снимать или выбирать фотографию. Может ли кто-нибудь сказать мне, почему он не отображается так же, как Apple? Это для iPad, поэтому я не объявил кнопку «Отмена».Remove Padding from UIActionSheet Popover

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

Попробуйте

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

Это получилось. Благодарю. – DenVog

2

Вам еще нужно объявить кнопку отмены. При запуске на IPad будет просто игнорировать кнопку отмены, в то время как на iPhone он будет использовать его

+0

Doh! Это объясняет это. Благодарю. – DenVog

+0

+1 Это настоящий ответ. –

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