如何在条形按钮项上调用操作表

时间:2011-03-24 07:56:20

标签: iphone objective-c

HI, 我想打电话到我左下方工具栏上的左侧栏按钮项目上的操作表。我该怎么做

1 个答案:

答案 0 :(得分:1)

设置按钮以运行'按下按钮',然后使用代码..

- (void)myButtonPressed:(id)sender
{
    UIActionSheet* action = [[UIActionSheet alloc] 
                         initWithTitle:@"Menu" 
                         delegate:self 
                         cancelButtonTitle:@"Continue"
                         destructiveButtonTitle:@"Quit" 
                         otherButtonTitles:@"Debug",nil ];
[action showInView:self.view];
[action release];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:   (NSInteger)buttonIndex {
switch (buttonIndex) {
    case 0: // continue
        NSLog(@"Continue");
        break;
    case 1: // Quit
        NSLog(@"Quit");
        break;
    case 2: // Debug
        NSLog(@"Debug");
        break;
}
}

在.h文件中

@interface ViewController : UIViewController <UIActionSheetDelegate>