创建一个弹出按钮接口 [英] Creating a pop up button interface

查看:111
本文介绍了创建一个弹出按钮接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在苹果的股票消息应用程序,轻按拍照键显示弹出式菜单按钮,允许用户拍摄照片/视频,或者选择一个现有的。我将如何实现此相同的按键设计?程序是相同的两个iPhone和放大器; iPad的?

In Apple's stock 'Messages' app, tapping the camera button reveals popup buttons allowing the user to take a photo/video or choose an existing one. How would I implemented this same button design? Is the procedure the same for both iPhone & iPad?

推荐答案

这就是所谓的一个 UIActionSheet 。您可以使用像这样

It's called a UIActionSheet. You use it like this

UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"Foo" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"foo1", @"foo2", nil];
[action showInView:self.view];

(改变FOOS到任何)。为了检测被点击哪个按钮,落实 UIActionSheetDelegate actionSheet:clickedButtonAtIndex:委托方法。例如:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSString *title = [actionSheet buttonTitleAtIndex:buttonIndex];
    if ([title isEqualToString:@"foo1"]) {
        // do stuff...
    }
}

是的,这部作品同时在iPhone和iPad(如@bobnoble指出,iPad版采用了酥料饼的观点,而不是动作片,但动作片在两个工作)。

And yes, this works on both the iPhone and iPad (as @bobnoble pointed out, the iPad version uses a popover view, not an action sheet, but action sheets work on both).

这篇关于创建一个弹出按钮接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆