2013-04-23 101 views
0

如何將uiactionsheet添加到uialertview中? 我也加進的tableview和alertview也想添加actionsheet其中具有四個按鍵 當我寫這些代碼,它提供了錯誤將UIActionsheet添加到UIAlertView中

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

泰伯維完全補充,但actionsheet不會增加。 那麼有沒有解決方案?

在此先感謝

回答

1

我建議不使用警報和簡單的動畫在屏幕上以顯示你想要什麼,因爲警報都有特定用途。它比聽起來容易得多。

2

老問題,但我會建議CXAlertView任何人到達這裏,通過谷歌

+0

歡迎堆棧溢出,並感謝您的貢獻。儘管鏈接到外部資源可能會有所幫助,但要構成真正的答案,通常需要上下文。請參閱[答案],特別是**爲鏈接**提供上下文。在這種情況下,解釋OP如何使用它來解決他們的問題。 – jerry 2014-02-19 21:16:05

相關問題