0

如何将 uiactionsheet 添加到 uialertview 中?我还将 tableview 添加到 alertview 中,并且还想添加具有四个按钮的操作表,当我编写这些代码时它会给出错误

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Preferences"
                                                    message:@"\n\n\n\n\n\n\n"
                                                   delegate:self
                                          cancelButtonTitle:@"Cancel"
                                          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
                                                            delegate:self
                                                   cancelButtonTitle:cancelTitle
                                              destructiveButtonTitle:destructiveTitle
                                                   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 完全添加,但 actionsheet 不会添加。那么有什么解决办法吗???

提前致谢

4

2 回答 2

2

老问题,但我会向通过谷歌到达这里的任何人推荐CXAlertView

于 2014-02-19T20:51:48.873 回答
1

我建议不要使用警报,而只是在屏幕上为视图设置动画以显示您想要的内容,因为警报具有特定目的。这比听起来容易得多。

于 2013-04-23T12:51:58.597 回答