iosでのプロンプトボックスの使用
3094 ワード
旧バージョンのプロンプトボックス
UIalertViewボタンのクリックイベントを取得するには、エージェントクラス:UIalertView Delegateを使用する必要があります.その後,その方法を実現すると,ボタンのクリックイベントを取得することができる.
下のプロンプトボックス
上記のプロンプトボックスと同様に、エージェントはUIActionSheetDelegateです.クリックするエージェントの方法は次のとおりです.
新しいヒントボックス
このプロンプトボックスには、コントロールを使用してポップアップをトリガーする必要があります.
新しいActionSheet
キャンセルプロンプトボックス
UIAlertView *alt=[[UIAlertView alloc]initWithTitle:@" " message:@" " delegate:self cancelButtonTitle:@" " otherButtonTitles:@" ", nil];
alt.delegate=self;
[alt show];
UIalertViewボタンのクリックイベントを取得するには、エージェントクラス:UIalertView Delegateを使用する必要があります.その後,その方法を実現すると,ボタンのクリックイベントを取得することができる.
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%ld",buttonIndex);
}
下のプロンプトボックス
UIActionSheet *sheet=[[UIActionSheet alloc] initWithTitle:@" " delegate:self cancelButtonTitle:@" " destructiveButtonTitle:@" " otherButtonTitles:@" ", nil];
[sheet showInView:self.view];
上記のプロンプトボックスと同様に、エージェントはUIActionSheetDelegateです.クリックするエージェントの方法は次のとおりです.
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
}
新しいヒントボックス
UIAlertController *controller=[UIAlertController alertControllerWithTitle:@" " message:@" " preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *act1=[UIAlertAction actionWithTitle:@" " style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *act2=[UIAlertAction actionWithTitle:@" " style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
[controller addAction:act1];
[controller addAction:act2];
[self presentViewController:controller animated:YES completion:^{
}];
このプロンプトボックスには、コントロールを使用してポップアップをトリガーする必要があります.
新しいActionSheet
UIAlertController *controller=[UIAlertController alertControllerWithTitle:@" " message:@" " preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *act1=[UIAlertAction actionWithTitle:@" " style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *act2=[UIAlertAction actionWithTitle:@" " style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
[controller addAction:act1];
[controller addAction:act2];
[self presentViewController:controller animated:YES completion:^{
}];
キャンセルプロンプトボックス
[self dismissViewControllerAnimated:YES completion:^{
}];