Iphone 是否可以将自定义uiview添加到UIViewAlert?
我有一个自定义的Iphone 是否可以将自定义uiview添加到UIViewAlert?,iphone,ios,objective-c,uiview,uialertview,Iphone,Ios,Objective C,Uiview,Uialertview,我有一个自定义的UIView,带有textfield、按钮和UIWebView。我想将此自定义UIView添加到UIAlertView以显示在屏幕上。我可以这样做吗?谢谢是的,您可以添加、需要设置适当的帧以及视图上的所有按钮操作 UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"test" message:@"\n\n\n\n\n\n\n\n\n\n\n" delegate:self cancelButtonTitle:nil o
UIView
,带有textfield
、按钮
和UIWebView
。我想将此自定义UIView
添加到UIAlertView
以显示在屏幕上。我可以这样做吗?谢谢是的,您可以添加、需要设置适当的帧以及视图上的所有按钮操作
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];
为什么要在自定义alertview中添加和显示它。您可以在子视图中显示它,并使用addSubview:方法显示它
请注意,alertview的目的是显示警报,而这是唯一的目的。UIView的目的是显示警报您确实可以这样做,但您的应用程序将被拒绝,如Apple在中所述。如果您仍然想这样做,那么只需
[alertView addSubview:view]代码>将起作用
我建议您制作自己的UIAlertView,但与UIAlertView相比,它具有更统一的设计和更好的用户体验。试试我添加的代码标签
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];
像这样添加任何控件,但只正确设置帧。。。根据您的需要..您可以,但您不应该这么做,您的应用程序将被apple拒绝。请阅读详细指南。因为我想在屏幕上显示它,并禁用UIViewController的所有交互功能推送UIAlertViewLook如果您对您的应用程序使用此自定义警报,它可能会被苹果拒绝。我知道,但如果我在UIVIewController上添加UIVIew,当UIView出现时,我无法禁用UIVIewController的交互。在这种情况下,我建议使用自定义库,如SVProgressHUD。我可以将自定义UIView添加到SVProgressHUD吗?@HTKT611抱歉,库使用错误RNBlurModalView。我在应用程序的某些部分使用了它,效果很好