如何将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不会增加。 那么有没有解决方案?
在此先感谢
欢迎堆栈溢出,并感谢您的贡献。尽管链接到外部资源可能会有所帮助,但要构成真正的答案,通常需要上下文。请参阅[答案],特别是**为链接**提供上下文。在这种情况下,解释OP如何使用它来解决他们的问题。 – jerry 2014-02-19 21:16:05