我想用UIAlertView
来显示照片。我使用下面的代码来显示警报,但是它不起作用。它显示了标题、一些空格和按钮OK。我不知道自己是否做错了什么,因为我是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
应该按原样使用,你不应该扰乱视图层次结构,这会让你的应用程序在苹果应用程序审查过程中被拒绝。请阅读有关UIAlertViews的苹果文档。因此,您不应该使用setValue: forKey:@"accessoryView"
和/或addSubview:
。下方的特定部分
子类注释
UIAlertView类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不能修改。
解决方案
1) 使用第三方,如CNPPopupController和许多其他可用的检查此链接
OR
2) 创建自己的。