警报正文中的URL

时间:2013-05-22 10:23:18

标签: ios

我们可以在警报正文中放置一个可点击的链接吗?点击链接应该打开邮件客户端。 我迫在眉睫的问题是,有没有人尝试过它,苹果会接受它。

警告显示'请通过“确定”按钮与“帮助台”联系以获取更多信息 - 点击“帮助台”,它应该打开邮件客户端。

2 个答案:

答案 0 :(得分:4)

关于UIAlertView Class Reference

的Apple文档
  
    

子类注释

         

UIAlertView类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不得修改。

  

因此,为了获得您所讨论的自定义类型,您必须继承UIAlertView这是不允许的,您的应用将被拒绝。

然而,UIAlertView实现的- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex; 实现有一些替代方案。

您可以只使用一个与链接相同的按钮,而不是只使用此方法

{{1}}

要确定按下了哪个按钮,请运行您的邮件客户端。

答案 1 :(得分:2)

我认为虽然Apple强烈建议不要向customizations添加UIAlertView,但您可以使用UIAlertView委托功能来检测哪个button被按下了根据需要做出反应。

UIAlertView *alert = [[UIAlertView alloc] init withWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Your Event you want fire", nil];

- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   switch(index)
        case 1:
              //fire Your Event you want fire
              break;
}

如果您使用UIAlertView进行某种更改,您可以创建自己的Custom AlertView尝试此link SO Questions