gpt4 book ai didi

带有照片的 iOS UIAlertView

转载 作者:行者123 更新时间:2023-11-29 02:33:51 26 4
gpt4 key购买 nike

我想使用 UIAlertView 来显示照片。我使用下面的代码来显示警报,但它不起作用。它仅显示标题、一些空格和“确定”按钮。我不知道我是否做错了什么,因为我是 iOS 新手。

-(IBAction)ButtonPressed:(id)sender
{
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"titel"
message:nil
delegate:nil //or self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(180, 10, 85, 50)];

[imageView setImage:@"dog.png"];
[av setValue:imageView forKey:@"accessoryView"];

[av show];
}

最佳答案

@Popeye 的说法是正确的:UIAlertView 应该按原样使用,您不应该弄乱 View 层次结构,否则您的应用程序将被 Apple 应用程序审核流程拒绝。请阅读Apple documentation regarding UIAlertViews 。因此,您不应该使用 setValue: forKey:@"accessoryView" 和/或 addSubview:。具体部分如下

Subclassing Notes

The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.

解决方案

1) 使用 3 方,例如 CNPPopupController和许多其他可用的检查 this链接

 OR

2) 创建您自己的。

关于带有照片的 iOS UIAlertView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26588176/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com