-1

I want to add 2 radio buttons in alert view in iOS sdk.

When I want to select First Radio Button and then i Click "ok" Button in Alert view then go to next screen(like abc.m) and when i want to select Second Radio Button then i Click "ok" Button in Alert view then go to next screen(like my.m).

   UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"CANCEL",nil];
    UIButton *Radiobutton = [UIButton buttonWithType:UIButtonTypeCustom];
    [Radiobutton setImage:[UIImage imageNamed:@"checkbox.png"] forState:UIControlStateNormal];
    [Radiobutton setImage:[UIImage imageNamed:@"checkboxed.png"] forState:UIControlStateSelected];
    [Radiobutton setFrame:CGRectMake(0, 0, 17, 17)];
    [Radiobutton addTarget:self action:@selector(checkboxButton:) forControlEvents:UIControlEventTouchUpInside];
    [alertView addSubview:Radiobutton];
    [alertView show];

can you help me?

Pankaj K.
  • 53
  • 7

1 Answers1

1

No this is not possible, the iOS SDK states that you should not change the view hierarchy:

Subclassing

Notes 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.

For more information about appearance and behavior configuration, see “Alert Views”.

Just create your own view and added as an subview.

rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • can i use popup screen for this functionality? – Pankaj K. Jul 07 '14 at 07:59
  • Depends what you mean by popup screen? You can easily build something like the `UIAlertView` you self, include in the dark background. But that would be too broad for an answer on stackoverflow. Als Radio button are not native to iOS and should be avoided in iOS. – rckoenes Jul 07 '14 at 08:02