gpt4 book ai didi

ios - 将 UIImageview 添加到 subview 后无法单击 UIAlertView 中的按钮

转载 作者:行者123 更新时间:2023-11-28 18:21:04 25 4
gpt4 key购买 nike

“确定”按钮不起作用。我知道它发生了,因为我添加了 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 不允许您添加 subview 或修改 View 层次结构。参见 https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html对于:

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.

并查看 https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/UIKitUICatalog/UIAlertView.html#//apple_ref/doc/uid/TP40012857-UIAlertView对于:

Appearance of Alert Views

You cannot customize the appearance of alert views.

违背这些原则会使您的应用在 Apple 审核流程中被拒绝 - 所以我会回头看看您的应用设计。

关于ios - 将 UIImageview 添加到 subview 后无法单击 UIAlertView 中的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20611444/

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