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

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

问题描述

我在 iTunes 商店有一个应用程序,它在 UIAlertView 上显示一些 UILabelUIWebView.根据会话视频,UIAlertViewaddSubView 将不起作用.他们谈到了ContentView.但是在 GM Seeds 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]

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

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