1

我不知道要搜索什么或它叫什么,因为我是全新的。请帮助我,当我按下按钮时,它会显示其他按钮。我们在很多应用程序中找到了它,但我不知道它的名字。我在下面附上了它的图片。如何在 iOS 应用程序中执行此操作。

选项

4

2 回答 2

2

被称为UIActionSheet

这是一个评估者复杂的例子:

    UIActionSheet *actionSheet = [[UIActionSheet alloc] init] ;
    actionSheet.title = @"Change pincode?";
    actionSheet.delegate = self;
    actionSheet.tag = kChangePincode;

    [actionSheet addButtonWithTitle:@"Chacge pincode"];
    [actionSheet addButtonWithTitle:@"Remove pin code"];

    [actionSheet addButtonWithTitle:@"cancel"];
    [actionSheet setCancelButtonIndex:(actionSheet.numberOfButtons - 1)];

    [actionSheet showInView:self.view];
于 2013-01-11T08:07:09.063 回答
0

浏览UIActionsheet。 做这样的插件

// 在 .h 类中

@interface MyViewController : UIViewController <UIActionSheetDelegate> {

    ...

}


...


-(IBAction)showActionSheet:(id)sender;

@结尾

在.m

-(IBAction)showActionSheet:(id)sender {
    UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive Button" otherButtonTitles:@"Other Button 1", @"Other Button 2", nil];
    popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    [popupQuery showInView:self.view];
    [popupQuery release];
}


// Handle Delegates-------------
    -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
        if (buttonIndex == 0) {
            self.label.text = @"Destructive Button Clicked";
        } else if (buttonIndex == 1) {
            self.label.text = @"Other Button 1 Clicked";
        } else if (buttonIndex == 2) {
            self.label.text = @"Other Button 2 Clicked";
        } else if (buttonIndex == 3) {
            self.label.text = @"Cancel Button Clicked";
        }

        /**
         * OR use the following switch statement
         * 
         */
        /*
        switch (buttonIndex) {
            case 0:
                self.label.text = @"Destructive Button Clicked";
                break;
            case 1:
                self.label.text = @"Other Button 1 Clicked";
                break;
            case 2:
                self.label.text = @"Other Button 2 Clicked";
                break;
            case 3:
                self.label.text = @"Cancel Button Clicked";
                break;
        }
        */
    }
于 2013-01-11T08:12:40.097 回答