简体   繁体   中英

UITableView positioning inside of a UIView

Ok so my question sounds silly because quite frankly, it is. So the programmer I am working with decided to place a UITablViewController inside of a UIView. Problem is that this is done throughout the app, and it is already pretty far along the process of implementing. I placed a refresh control to a UITableviewController like so:

[self.categoryList addSubview:self.refreshControl];

So here's where my question begins to fold out. Without the logic below, the UITableView shifts below (Refresh control is perfect visible). However, if I don't use this code, I get an awkward gap: (But to emphasize, the refresh control is perfectly visible without this logic.)

if([[UIDevice currentDevice].systemVersion floatValue]>=7.0)
       [self.categoryList setFrame:CGRectMake(0, -18, 320, self.categoryList.frame.size.height+35)];

Awkward gap without code:

//////////////////

RefreshControl Works

/////////////////

But here's the problem. This logic makes the refresh control hide behind the navbar. I realize that using a UITableviewController fixes this problem naturally. But, since we are so far in this app already using a UIViewcontroller, I think the best move is to stick with what we got. So how would I position this UITableView list appropriately without the refresh control hiding behind the navbar? Hopefully I explained my problem clearly for everyone.

Sounds like you're running into an issue that I've run into with UIScrollView s. Unfortunately it's a bug when a UIScrollView is placed such that it is closest to the NavigationBar . It'll automatically inset the scrollview by the height of the UINavBar . So the only real solution that I've found is:

[myView setContentInset:UIEdgeInsetsMake(-self.navigationController.navigationBar.frame.size.height, 0, 0, 0)];

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