iOS UIActionSheet

UIActionSheet在部份選單中還蠻好用的,其中如果有不需要的按鈕只要將String部份輸入為"nil"按鈕就會自動消失了!

UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"cancel" otherButtonTitles:@"AAA", @"BBB", @"CCC", @"DDD", nil];
myActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[myActionSheet showInView:self.view];


使用時如果有需要知道按下的按鈕是哪一個記得在.h檔中加入"UIActionSheetDelegate",並在.m檔中加入以下Delegate,"buttonIndex"就是由上往下算的按鈕數目,從"0"開始。
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"buttonIndex = %d", buttonIndex);
}


相關連結
iOS Developer Library
iOS Developer Library - UIActionSheet

沒有留言:

張貼留言