UIActionSheet spa
.h 文件 it
@interface ViewController : UIViewController<UIActionSheetDelegate>
- (IBAction)ShowActionSheet:(id)sender; io
.m 文件 cli
- (IBAction)ShowActionSheet:(id)sender{
UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:@"Hello" delete:self cancelButtonTitle:@"取消" desturctiveButtonTitle:@"第一項" otherButtonTitles:@"第二項",@"第三項",nil];
actionSheet.actionSheetStyle=UIActionSheetStyleAutomatic; //灰色背景 和 Default同樣
*UIActionSheetStyleBlackTranslucent //黑色半透明背景
*UIActionSheetStyleBlackOpaque //純黑色背景
*UIActionSheetStyleBlackDefault //灰色背景
[actionSheet showInView:self.view];
} 文件
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex=X){do...}
} view
UIAlertView vi
.h 文件 let
@Interface ViewController:UIViewController<UIAlertViewDelegate> interface
.m 文件 void
- (void)ShowAlertView{
UIAlertView *alert=[UIAlertView alloc]initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles@"One",@"Two",nil);
[alert Show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog(@"buttonIndex:%d",buttonIndex); }