简体   繁体   中英

UIView not appearing on top of UITableView

I have a UIViewController with a UITableView on top of it. I am trying to put a small UIView overlay on top of the table view. I added it both programatically (and used bringSubviewToFront ), and then in Interface Builder and it does not appear either way.

Why is that? How can I add the UIView overlay on top of the table view?

EDIT:

I am not using a UITableViewController . It's a UIViewController with a UITableView . Here is the code I used in viewDidLoad :

UIView *joinMediame = [[UIView alloc] initWithFrame:CGRectMake(0, 44, 320, 44)];
joinMediame.backgroundColor = [UIColor orangeColor];
[self.view addSubview:joinMediame];
[self.view bringSubviewToFront:joinMediame];

If you are intending for your view to scroll with the table content, I would make it the tableHeaderView of the table. If you want the view to be static at the top, I would add it as a subview of the controller and then resize the table view frame to make room for the static view.

Note that if the controller is a UITableViewController , self.view is a UITableView , so if you do something like [self.view addSubview:staticView] this won't have the effect you expect.

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