0

どうすれば uiactionsheet を uialertview に追加できますか??? また、テーブルビューをアラートビューに追加し、これらのコードを書いたときにエラーが発生する4つのボタンを持つアクションシートを追加したい

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

テーブルビューは完全に追加されますが、アクションシートは追加されません。それで、利用可能な解決策はありますか????

前もって感謝します

4

2 に答える 2

1

アラートには特定の目的があるため、アラートを使用せず、単に画面上のビューをアニメーション化して必要なものを表示することをお勧めします。思ったよりずっと簡単です。

于 2013-04-23T12:51:58.597 に答える