如何将userInfo添加到UIAlertView? [英] How to add userInfo to a UIAlertView?

查看:194
本文介绍了如何将userInfo添加到UIAlertView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何将一个userInfo对象或任何NSDictionary添加到UIAlertView?

I would like to know how to add a userInfo object, or any NSDictionary, to a UIAlertView?

谢谢。

推荐答案

如果您在> iOS 4.0(对于块)并且您只需要一个或两个按钮,则可以使用此类别:

If you are on > iOS 4.0 (for blocks) and you only want one or two buttons, you could use this category I made:

https://github.com/rsaunders100/UIAlertView-Blocks

它绕过了添加用户信息的需要,因为您将点击handeling功能直接放入警报中。例如

It bypasses the need to add user info since you put your click handeling function straight into the alert. e.g.

 #import UIAlertView+Blocks.h

 ...

 ...

 NSString* myUserInfo = @"example";

 [UIAlertView displayAlertWithTitle:@"Example Alert View With Blocks"
                            message:nil
                    leftButtonTitle:@"Ok"
                  leftButtonAction:^{
                                      NSLog(@"%@", myUserInfo);
                                    } 
                  rightButtonTitle:nil
                 rightButtonAction:nil];

这篇关于如何将userInfo添加到UIAlertView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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