[英]iOS how to add a view to screen center and stick it to screen center on a UITableViewController?
我正在UITableViewController
。 我必须显示一个包含一些信息的view
,该视图将以编程方式添加到TableViewController
。 这是我添加它的代码:
MyNotificationView *notificationView = // some initializations;
[self.view addSubview:notificationView]; // self is the UITableViewController
notificationView.center = self.view.center;
但是,在UITableViewController
,此代码实际上将我的notificationView
的中心设置为TableViewController
的可滚动区域的中心,并且我的notificationView
随TableView
滚动而滚动。 我想要的是将我的notificationView
添加到屏幕中心并将其粘贴在屏幕中心,那么该怎么办呢?
您可以创建一个UIViewController,使其内部具有UITableView,并希望将其居中放置在NotificationView中,只需将其添加到视图[self.view addSubview:notificationView];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.