メッセージに返信するときに、メール アプリにあるようなポップアップ メニューを作成したいと考えています。私はこれを複数のアプリケーションで見たことがあるので、フレームワークに何かが組み込まれているのか、それともサンプルコードがそこにあるのかはわかりませんでした.
26882 次
7 に答える
20
これは、UIAlertController
iOS 8 以降では であり、それUIActionSheet
以前のバージョンでは です。
于 2009-05-26T15:00:29.860 に答える
14
Apple の Web サイトで UICatalog の例を確認してください。「アラート」セクションには、UIActionSheet を使用して目的を達成する方法の例があります。
于 2009-05-26T15:23:42.213 に答える
9
UIActionSheet を使用する必要があります。
まず、UIActionSheetDelegate を ViewController .h ファイルに追加する必要があります。
次に、アクションシートを次のように参照できます。
UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Select Sharing option:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:
@"Share on Facebook",
@"Share on Twitter",
@"Share via E-mail",
@"Save to Camera Roll",
@"Rate this App",
nil];
popup.tag = 1;
[popup showInView:self.view];
次に、各呼び出しを処理する必要があります。
- (void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (popup.tag) {
case 1: {
switch (buttonIndex) {
case 0:
[self FBShare];
break;
case 1:
[self TwitterShare];
break;
case 2:
[self emailContent];
break;
case 3:
[self saveContent];
break;
case 4:
[self rateAppYes];
break;
default:
break;
}
break;
}
default:
break;
}
}
これは、iOS 8.x で非推奨になりました。
于 2014-04-22T16:38:28.620 に答える
5
これは、iOS 8 以降の Objective-C で行う方法です。
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Directions"
message:@"Select mode of transportation:"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *drivingAction = [UIAlertAction actionWithTitle:@"Driving" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// this block runs when the driving option is selected
}];
UIAlertAction *walkingAction = [UIAlertAction actionWithTitle:@"Walking" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// this block runs when the walking option is selected
}];
UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
[alert addAction:drivingAction];
[alert addAction:walkingAction];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
于 2015-12-03T12:52:12.713 に答える
2
Swift で解決策を探しているすべての人へ:
UIActionSheetDelegate
プロトコルを採用ActinSheet を作成して表示します。
let sheet: UIActionSheet = UIActionSheet() sheet.addButtonWithTitle("button 1") sheet.addButtonWithTitle("button 2") sheet.addButtonWithTitle("button 3") sheet.addButtonWithTitle("Cancel") sheet.cancelButtonIndex = sheet.numberOfButtons - 1 sheet.delegate = self sheet.showInView(self.view)
デリゲート関数:
func actionSheet(actionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int){ switch buttonIndex{ case 0: NSLog("button1"); case 1: NSLog("button2"); case 2: NSLog("button3"); case actionSheet.cancelButtonIndex: NSLog("cancel"); break; default: NSLog("blub"); break; } }
于 2015-09-08T08:44:51.997 に答える