用户登录
用户注册

分享至

iOS警告框和操作表示例

  • 作者: 没有猫也没有你99386891
  • 来源: 51数据库
  • 2022-08-17
//
//  ViewController.m
//
//  Created by dengw on 15/7/28.
//  Copyright (c) 2015年 dengwei. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIAlertViewDelegate,UIActionSheetDelegate>
- (IBAction)alertViewButton:(id)sender;
- (IBAction)actionSheetButton:(id)sender;
?
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
}

- (IBAction)alertViewButton:(id)sender {
????UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Alert text goes here" delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
????[alertView show];
}
?
#pragma mark? 实现UIAlertViewDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
????NSLog(@"buttonIndex = %li", buttonIndex);
}

- (IBAction)actionSheetButton:(id)sender {
????UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"破坏性按钮" otherButtonTitles:@"Facebook", @"新浪微博", nil];
????actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;
????[actionSheet showInView:self.view];
}
?
#pragma mark? 实现UIActionSheetDelegate
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
????NSLog(@"buttonIndex = %li", buttonIndex);
}

@end
软件
前端设计
程序设计
Java相关