- #import "ActionSheetTestViewController.h"
- @implementation ActionSheetTestViewController
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - (void)viewDidLoad {
- UILabel *numOfBtn = [[UILabel alloc]initWithFrame:CGRectMake(10.0, 10.0, 30.0, 30.0)];
- UILabel *titleOfBtn = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 10.0, 100.0, 30.0)];
- UILabel *cancelBtnIndex = [[UILabel alloc]initWithFrame:CGRectMake(200.0, 10.0, 30.0, 30.0)];
- UILabel *destructiveBtnIndex = [[UILabel alloc]initWithFrame:CGRectMake(10.0, 50.0, 30.0, 30.0)];
- UILabel *firstOtherBtnIndex = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 50.0, 30.0, 30.0)];
- UIActionSheet *actionSheetTest = [[UIActionSheet alloc]initWithTitle:@"ActionSheetTest"
- delegate:self
- cancelButtonTitle:@"CancelButton"
- destructiveButtonTitle:@"RedButton"
- otherButtonTitles:@"OtherButton1",@"OtherButton2",nil];
-
- BOOL a = actionSheetTest.visible;
- NSLog(@"%d",a);
-
-
- [actionSheetTest dismissWithClickedButtonIndex:0 animated:NO];
-
-
- actionSheetTest.title = @"ActionSheetTitle";
-
-
- [actionSheetTest addButtonWithTitle:@"addButtonWithTitle"];
-
-
- numOfBtn.text = [NSString stringWithFormat:@"%d",actionSheetTest.numberOfButtons];
-
-
- titleOfBtn.text = [actionSheetTest buttonTitleAtIndex:4];
-
-
- cancelBtnIndex.text = [NSString stringWithFormat:@"%d",actionSheetTest.cancelButtonIndex];
-
-
- destructiveBtnIndex.text = [NSString stringWithFormat:@"%d",actionSheetTest.destructiveButtonIndex];
-
-
- firstOtherBtnIndex.text = [NSString stringWithFormat:@"%d",actionSheetTest.firstOtherButtonIndex];
-
-
- [actionSheetTest showInView:self.view];
-
- [self.view addSubview:numOfBtn];
- [self.view addSubview:titleOfBtn];
- [self.view addSubview:cancelBtnIndex];
- [self.view addSubview:destructiveBtnIndex];
- [self.view addSubview:firstOtherBtnIndex];
-
- [actionSheetTest release];
- [numOfBtn release];
- [titleOfBtn release];
- [cancelBtnIndex release];
- [destructiveBtnIndex release];
- [firstOtherBtnIndex release];
-
- [super viewDidLoad];
- }
-
-
-
-
-
-
-
-
- - (void)didReceiveMemoryWarning {
-
- [super didReceiveMemoryWarning];
-
-
- }
- - (void)viewDidUnload {
-
-
- }
-
- - (void)dealloc {
- [super dealloc];
- }
-
- #pragma mark -- UIActionSheetDelegate --
-
- - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
- NSLog(@"clickedButtonAtIndex:%d",buttonIndex);
- }
-
- - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
- NSLog(@"didDismissWithButtonIndex:%d",buttonIndex);
- }
-
- - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex {
- NSLog(@"willDismissWithButtonIndex:%d",buttonIndex);
- }
-
- - (void)actionSheetCancel:(UIActionSheet *)actionSheet {
- NSLog(@"actionSheetCancel");
-
- }
-
- - (void)didPresentActionSheet:(UIActionSheet *)actionSheet {
- NSLog(@"didPresentActionSheet%@",actionSheet);
- }
-
- - (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
- NSLog(@"willPresentActionSheet%@",actionSheet);
- }
-
- @end
原文转载:http://blog.csdn.net/banyingli/article/details/6167561