简体   繁体   中英

UIView over UITableViewController

I need to place a UIView over UITableViewController , for now i placed it this way

[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

Is there a way to make that my UIView will be cover another VC together with UITableViewController ?

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. You can use

[self.navigationController.view addSubview:searchView];

UITableViewControllers in fact also have a view property which you can add subviews to. So my advice would be to just send [self.view addSubview:searchView]; inside the table view controller, so that it will be moved alongside the table view, when pushing another controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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