Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何将UITableView添加到UIAlertView?_Iphone - Fatal编程技术网

Iphone 如何将UITableView添加到UIAlertView?

Iphone 如何将UITableView添加到UIAlertView?,iphone,Iphone,我创建了一个类: @接口myUITableViewController:UIViewController { NSArray*列表数据; } 后来,我这样做: UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; myUITableViewController *myUI

我创建了一个类:

@接口myUITableViewController:UIViewController { NSArray*列表数据; }

后来,我这样做:

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:nil    delegate:self cancelButtonTitle:nil otherButtonTitles:nil];

myUITableViewController *myUITable = [[myUITableViewController alloc] init];

[alert addSubview:myUITable.view];

[alert show];
运行后,结果是myUITable.view的大小大于alert。 为什么? 如果你知道,请告诉我。
谢谢大家!

UIAlert并不是真的要这样使用的。您应该创建自己的自定义UIView,并在其中添加所需的任何内容(表和按钮)。然后处理它如何显示和隐藏自己


即使你能把它正确地显示出来,将来它也有可能会坏掉。在我的一个应用程序中,我显示了一个带有UITextField的警报。我在邮件中添加了“\n”以腾出空间。在后来的iOS版本中,这个功能停止工作,看起来非常糟糕……

我不同意。Yelp应用程序使用这种方法(用于“你的意思是:”对话框),它看起来很棒。我在网站上找到了类似的代码。