-2

I have a custom UIView with textfield, button and UIWebView. I want to add this custom UIView to UIAlertView to show on Screen. Can I do that? Thanks

Girish
  • 4,692
  • 4
  • 35
  • 55
HTKT611
  • 161
  • 1
  • 1
  • 11

4 Answers4

3

You indeed can do that, however your app will get rejected, as described in the Human Interface Guidelines by Apple. If you still want to do that then just [alertView addSubview:view]; will work.

I would suggest making your own UIAlertView, but with more unified design and better UX than how it would look in the UIAlertView.

Dominik Hadl
  • 3,609
  • 3
  • 24
  • 58
1

Why go for adding and showing in custom alertview .You can show it in a subview and present it using the addSubview: method

Note the purpose of alertview is to present an alert and it alone is the sole purpose.The UIView is there for the purpose of presenting it

Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
0

yes,you can add,need to set proper frames and all those things like button actions on the view.

 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];
Balu
  • 8,470
  • 2
  • 24
  • 41
0

Try this Code i am adding Label.

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];

Adding like this whatever your control but only setting Frames Properly... As per your Need..

Jitendra
  • 5,055
  • 2
  • 22
  • 42