1、案例介紹:點擊第一個按鈕彈出提示框;點擊第二個按鈕彈出操做表。如圖01,圖02,圖03spa
圖01
圖02
圖03code
2、案例步驟:blog
一、選擇Simple View Aplication,取名cq.32.警告框和操做表,如圖04it
二、Main.storyboardio
三、CQ32ViewController.h微博
#import <UIKit/UIKit.h> @interface CQ32ViewController : UIViewController<UIAlertViewDelegate,UIActionSheetDelegate> - (IBAction)testAlertView:(id)sender; - (IBAction)testActionSheet:(id)sender; @end
四、CQ32ViewController.mclass
- (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); }