iOS.UIKit.07.UIAlertView_UIActionSheet

一、案例介绍:点击第一个按钮弹出提示框;点击第二个按钮弹出操作表。如图01,图02,图03

iOS.UIKit.07.UIAlertView_UIActionSheet图01iOS.UIKit.07.UIAlertView_UIActionSheet图02iOS.UIKit.07.UIAlertView_UIActionSheet图03

二、案例步骤:

1、选择Simple View Aplication,取名cq.32.警告框和操作表,如图04

iOS.UIKit.07.UIAlertView_UIActionSheet

2、Main.storyboard

iOS.UIKit.07.UIAlertView_UIActionSheet

3、CQ32ViewController.h

iOS.UIKit.07.UIAlertView_UIActionSheet
#import <UIKit/UIKit.h>

@interface CQ32ViewController : UIViewController<UIAlertViewDelegate,UIActionSheetDelegate>

- (IBAction)testAlertView:(id)sender;
- (IBAction)testActionSheet:(id)sender;

@end
iOS.UIKit.07.UIAlertView_UIActionSheet

4、CQ32ViewController.m

iOS.UIKit.07.UIAlertView_UIActionSheet
- (IBAction)testAlertView:(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 = %i",buttonIndex);
}

- (IBAction)testActionSheet:(id)sender
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"破坏性按钮" otherButtonTitles:@"新浪微博", nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;
    [actionSheet showInView:self.view];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSLog(@"buttonIndex = %i",buttonIndex);
}
iOS.UIKit.07.UIAlertView_UIActionSheet

 

iOS.UIKit.07.UIAlertView_UIActionSheet,布布扣,bubuko.com

iOS.UIKit.07.UIAlertView_UIActionSheet

上一篇:iOS开发 UITableView的方法和属性总结


下一篇:Android:自定义控件样式(Selector)