如何在UIAlertView for iOS 7中添加子视图? [英] How to add subview inside UIAlertView for iOS 7?

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

问题描述

我在iTunes商店有一个应用程序,它在上显示一些 UILabel UIWebView UIAlertView中。根据会话视频, addSubView for UIAlertView 将无效。他们谈过 ContentView 。但是在GM种子SDK中,我找不到那个属性,似乎没有别的办法。

I am having an application on iTunes store which displays some UILabel and UIWebView on UIAlertView. According to session video, addSubView for UIAlertView will not work. They have talked about ContentView. But in the GM Seeds SDK, I could not find that property and there seems to be no other way.

我唯一能做的就是创建一个自定义子类 UIView 并使其像 UIAertView 一样工作。你能建议任何其他简单的解决方案吗?

The only thing I can do is to create a custom subclass of UIView and make it work like UIAertView. Can you suggest any other simple solution?

感谢您的帮助。

推荐答案

您可以在iOS7中将 accessoryView 更改为 customContentView (在iOS8中似乎也是如此)UIAlertView

You can really change accessoryView to customContentView in iOS7 (and it seems that in iOS8 as well) UIAlertView

[alertView setValue:customContentView forKey:@"accessoryView"];

试用此代码:

UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"TEST" message:@"subview" delegate:nil cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
[av setValue:v forKey:@"accessoryView"];
v.backgroundColor = [UIColor yellowColor];
[av show];

请记住,在调用之前,您需要设置自定义 accessoryView alertView show]

Remember that you need set custom accessoryView before the call [alertView show]

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

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