Agregar hoja de acción de UIA en UIAlertView

How can i add uiactionsheet into uialertview ??? I am also add tableview into alertview and also want to add actionsheet which having four buttons when i wrote these code its gives error

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Preferences"
                                          otherButtonTitles:@"OK", nil];

    UITableView *myView = [[[UITableView alloc] initWithFrame:CGRectMake(10, 40, 264, 150)
                                                        style:UITableViewStylePlain] autorelease];
    myView.delegate = self;
    myView.dataSource = self;

    [alert addSubview:myView];

   NSString *actionSheetTitle = @"Action Sheet Demo"; //Action Sheet Title
   NSString *destructiveTitle = @"Destructive Button"; //Action Sheet Button Titles
   NSString *other1 = @"Other Button 1";
   NSString *other2 = @"Other Button 2";
   NSString *other3 = @"Other Button 3";
   NSString *cancelTitle = @"Cancel Button";

   UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:actionSheetTitle
                                                   otherButtonTitles:other1, other2, other3, nil];

   UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(10, 250, alert.frame.size.width, 250)];
   tempView.backgroundColor = [UIColor redColor];
   tempView.clipsToBounds = YES;
   [alert addSubview:tempView];

   [alert addSubview:actionSheet];
  [alert show];
    [actionSheet showInView:tempView];
     [myView reloadData];

Tableview completely add but actionsheet will not add. So is there any solution available????

Gracias por adelantado

preguntado el 23 de abril de 13 a las 12:04

2 Respuestas

Old question, but I would recommend CXAlertView for anyone getting here through google

Respondido 19 Feb 14, 20:02

Welcome to Stack Overflow and thanks for your contribution. While a link to an external resource can be helpful, to constitute a real answers it often requires context. Please see Cómo responder, concretamente la sección Proporcionar contexto para los enlaces. In this case, explain how the OP would use this to solve their problem. - jerry

I would recommend not using an alert and simply animate a view on screen to display what you want since an alert has a specific purpose. It's much easier than it sounds.

Respondido 23 Abr '13, 13:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.