【问题标题】:Can add custom uiview to UIViewAlert? [closed]可以将自定义 uiview 添加到 UIViewAlert 吗? [关闭]
【发布时间】:2013-07-19 09:03:37
【问题描述】:

我有一个自定义的UIViewtextfieldbuttonUIWebView。我想将此自定义 UIView 添加到 UIAlertView 以显示在屏幕上。我可以这样做吗?谢谢

【问题讨论】:

  • 可以,但不应该
  • 不要这样做,你的应用会被苹果拒绝。请阅读 HIG 指南。
  • 因为我想在屏幕上显示它并禁用 UIViewController push UIAlertView 的所有交互
  • 如果您为您的应用使用此自定义提醒,它可能会被 Apple 拒绝。

标签: iphone ios objective-c uiview uialertview


【解决方案1】:

您确实可以这样做,但是您的应用会被拒绝,如 Apple 的 Human Interface Guidelines 中所述。如果您仍然想这样做,那么只需 [alertView addSubview:view]; 即可。

我建议您制作自己的 UIAlertView,但与 UIAlertView 中的外观相比,它具有更统一的设计和更好的用户体验。

【讨论】:

    【解决方案2】:

    为什么要在自定义警报视图中添加和显示。您可以在子视图中显示它并使用 addSubview: 方法显示它

    注意 alertview 的目的是呈现警报,它是唯一的目的。UIView 的目的是为了呈现它

    【讨论】:

    • 我知道,但是如果我在 UIVIewController 上添加 UIVIew,当 UIView 出现时,我无法禁用 UIVIewController 的交互
    • 那么在这种情况下,我会建议使用像 SVProgressHUD 这样的自定义库
    • 我可以将自定义 uiview 添加到 SVProgressHUD 吗?
    • @HTKT611 对不起,图书馆使用 RNBlurModalView 错误。我在应用程序中使用它并且像魅力一样工作
    【解决方案3】:

    是的,你可以添加,需要设置适当的框架和所有这些东西,比如视图上的按钮操作。

     UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"test" message:@"\n\n\n\n\n\n\n\n\n\n\n" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
        UIView *view= [[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];
        view.backgroundColor = [UIColor redColor];
        [alert addSubview:view];
        [alert show];
    

    【讨论】:

      【解决方案4】:

      试试这个代码,我正在添加标签。

      delegate.alert=[[UIAlertView alloc]initWithTitle:@"Password" message:@"\n\n\n\n\n" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
      
          delegate.lbl=[[UILabel alloc]init];
          delegate.lbl.frame=CGRectMake(60, 42, 200, 18);
      
          delegate.lbl.backgroundColor=[UIColor clearColor];
          [delegate.alert addSubview:delegate.lbl];
      

      无论您的控制如何,都可以像这样添加,但只能正确设置框架...根据您的需要..

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-05-17
        • 1970-01-01
        • 1970-01-01
        • 2014-08-09
        • 2019-10-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多