UIAlertView标题不显示 [英] UIAlertView title does not display

查看:94
本文介绍了UIAlertView标题不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了如下警报

UIAlertView *alert1 = [[UIAlertView alloc]
                           initWithTitle:@"Title"
                           message:@"message"
                           delegate:self
                           cancelButtonTitle:@"Cancel"
                           otherButtonTitles:nil];

 [alert1 show];

但是它不显示标题.我怎样才能解决这个问题?

But it does not display the title. How can I fix this?

推荐答案

我尝试在您的代码中的Xcode 5.1.1在我的Xcode中正常工作,请参见输出

I try in Xcode 5.1.1 in your code is working fine in my Xcode, see the output

并且我也尝试Xcode 6.0.1您的代码在我的Xcode中工作正常,请参见输出

and i also try in Xcode 6.0.1 your code is working fine in my Xcode, see the output

如果您在swift的中使用

if u r using in Xcode 6.0.1 in swift

不推荐使用UIAlertView.使用UIAlertController的preferredStyle为 改为使用UIAlertControllerStyleAlert.

UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead.

UIAlertController * alert1 = [UIAlertController alertControllerWithTitle:@"Title" message:@"Message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* aaction = [UIAlertAction actionWithTitle:@"okay" style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction * action) {
                                                      [alert1 dismissViewControllerAnimated:YES completion:nil];
                                                  }];
[alert1 addAction:aaction];
[self presentViewController:alert1 animated:YES completion:nil];

另一种选择

 let alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert)

    let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
    alertController.addAction(defaultAction)

    presentViewController(alertController, animated: true, completion: nil)

需要更多帮助,请使用此链接 http://www.appcoda.com/uialertcontroller-swift-closures-enum/

need more help use this link http://www.appcoda.com/uialertcontroller-swift-closures-enum/

这篇关于UIAlertView标题不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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