繁体   English   中英

将UIImageview添加到subView后,无法单击UIAlertView中的按钮

[英]Cant click on button in UIAlertView after adding UIImageview to subView

确定按钮不起作用。 我知道这是因为我添加了backgroundImageView。 我该如何运作?

这是我的代码:

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"clock"]];

backgroundImageView.frame = CGRectMake(0, 0, 282, 200);

backgroundImageView.contentMode = UIViewContentModeScaleToFill;
backgroundImageView.userInteractionEnabled = YES;

[alert addSubview:backgroundImageView];

[alert sendSubviewToBack:backgroundImageView];

[alert show];

不幸的是,Apple不允许您添加子视图或修改视图层次结构。 请参阅https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html,以了解:

UIAlertView类旨在按原样使用,并且不支持子类化。 此类的视图层次结构是私有的,不能修改。

并请参见https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/UIKitUICatalog/UIAlertView.html#//apple_ref/doc/uid/TP40012857-UIAlertView

警报视图的外观

您无法自定义警报视图的外观。

违反这些规定将使您的应用程序在Apple Review流程中被拒绝-因此,我将回头研究您的应用程序设计。

Apple不允许您将子视图添加到UIAlertView 不能对UIAlertView进行子类化,也不希望此类被子类化,这样做可能是应用程序拒绝的原因。

您可以从此处使用库来自定义UIAlertView

不要将子视图添加到UIAlertView ,这是不受支持的功能。 如果您需要创建自定义视图,请找到支持您所需内容的第三部分警报视图解决方案,而改用它。

Apple不建议将子视图添加到UIAlertView您将必须创建自己的警报视图。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM