このコードはiPhoneでは正常に機能しますが、iPadではアクションシートが画面の中央に表示されます。トリガーボタンがあるコーナーではありません。また、キャンセルボタンは表示されません。
また、アプリはランドスケープモードのみです。カメラトリガーボタンは画面の右上隅にあります。
mediaPicker = [[UIImagePickerController alloc] init];
mediaPicker.allowsEditing = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Take photo", @"Choose Existing", nil];
//[actionSheet showInView:self.view];
[actionSheet showInView:self.navigationController.view];
}
// If device doesn't has a camera, Only "Choose Existing" and "Cancel" options will show up.
else {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Choose Existing", nil];
[actionSheet showInView:self.view];
}
ボタンの場所を表示するためのアクションシートが必要です。どうすればいいですか。