myUITableViewController

myUITableViewController

本文介绍了如何将UITableView添加到UIAlertView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个班级:

@interface myUITableViewController:UIViewController{NSArray * listData;}...

@interface myUITableViewController : UIViewController{ NSArray *listData;}...

稍后,我这样做:

    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的大小大于警报的大小.为什么?请告诉我你是否知道.谢谢!

After running,the result is that the myUITable.view's size is bigger than alert.Why?Please tell me if you know.Thank you!

推荐答案

UIAlert并不是真的要那样使用.您应该制作自己的自定义UIView,并在其中添加所需的任何内容(表格和按钮).然后处理它的显示方式并隐藏自己.

UIAlert is not really meant to be used like that. You should make your own custom UIView and add whatever content you need in it (the table and buttons). Then handle how it shows and hide yourself.

即使您设法使其正确显示,将来也可能会损坏.在我的一个应用程序中,我正在显示带有UITextField的警报.我通过在消息中添加"\ n"来腾出空间.在更高的iOS版本中,它停止工作,看起来真的很糟糕...

Even if you manage to get it shown correctly chances are it might break in the future. In one of my apps i was showing an alert with a UITextField. I was making space for it by adding "\n" to the message. In later iOS versions this stopped working and it looked really awful...

这篇关于如何将UITableView添加到UIAlertView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 08:25