[英]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.