简体   繁体   English

通过UITableViewController的UIView

[英]UIView over UITableViewController

I need to place a UIView over UITableViewController , for now i placed it this way 我需要将UIView放在UITableViewController ,现在我以这种方式放置它

[self.navigationController.view addSubview:searchView];

But problem is that - when i push this UITableViewController by another - my UIView is not pushed away with UITableViewController , but still hang up there, of course i just can remove it with animation, but it looks crapy enough 但是问题是-当我将UITableViewController推到另一个位置时-我的UIView没有被UITableViewController推开,但是仍然挂在那里,当然我可以用动画将其删除,但是看起来已经很粗糙了

Is there a way to make that my UIView will be cover another VC together with UITableViewController ? 有没有办法使我的UIView与UITableViewController一起覆盖另一个VC?

Thanks! 谢谢!

You can't use [self.view addSubview:searchView] as in that case self.view is UITableview only so this will add the searchview on tableview and your view will also scroll with the tableview. 不能使用[self.view addSubview:searchView]在这种情况下, self.view是UITableView的只有那么这将增加在tableview中的搜索查看与您的观点也将与实现代码如下滚动。 You can use 您可以使用

[self.navigationController.view addSubview:searchView];

UITableViewControllers in fact also have a view property which you can add subviews to. 实际上, UITableViewControllers也具有view属性,您可以向其中添加子视图。 So my advice would be to just send [self.view addSubview:searchView]; 所以我的建议是只发送[self.view addSubview:searchView]; inside the table view controller, so that it will be moved alongside the table view, when pushing another controller. 在表格视图控制器内部,以便在按下另一个控制器时将其移到表格视图旁边。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM