「Xamarin.iOSでダイアログを表示する」を編集中
ナビゲーションに移動
検索に移動
この編集を取り消せます。 下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
3行目: | 3行目: | ||
iOS8以降ではUIAlertControllerを使えとのこと。 | iOS8以降ではUIAlertControllerを使えとのこと。 | ||
<source lang="csharp"> | <source lang="csharp"> | ||
− | + | var alert = UIAlertController.Create("title", "message", UIAlertControllerStyle.Alert); | |
− | + | alert.AddAction(UIAlertAction.Create("NO", UIAlertActionStyle.Cancel , (handler) => { | |
− | + | Console.WriteLine("NO"); | |
− | + | })); | |
− | + | alert.AddAction(UIAlertAction.Create("YES", UIAlertActionStyle.Default, (handler) => { | |
− | + | Console.WriteLine("YES: " + alert.TextFields[0].Text); | |
− | + | })); | |
− | + | alert.AddTextField((textfield) => { | |
− | + | textfield.Placeholder = "textfield"; | |
− | + | // | |
− | + | var label = new UILabel(new CGRect(0, 0, 80, 30)); | |
− | + | label.Text = "LABEL: "; | |
− | + | textfield.LeftView = label; | |
− | + | textfield.LeftViewMode = UITextFieldViewMode.Always; | |
− | + | }); | |
− | + | this.PresentViewController(alert, animated: true, completionHandler: null); | |
</source> | </source> | ||