So I'm more or less trying to do this:
How to embed a UITableView in a UIScrollview
however, I can't seem to figure out how to obtain a 'subview' (I use quotes as I'm not sure it's officially a subview per the API however it lives within another view of a VC) so that I can then set it as the UITableView's header. Additionally, going through all the options available in the storyboard I don't see how to set it as the UITableView's header there either. I would greatly appreciate any help!
Relevant storyboard shots, here is the hierarchy:
And here's what the UITableViewController itself looks like. I'm trying to set the grey block as the header so that it doesn't scroll:
Programmatically this is what I'm looking to accomplish (assuming I'm on the right track!):
UIView *viewForHeader = [[self tableView] SOMEWAYTOGETTHEINNERVIEW?];
[[self tableView] setTableHeaderView:viewForHeader]
and if I can somehow set the view as the header in XCode 5 with iOS 7 that would be great as well! It seems in older versions for this situation the view would default as the header:
You can create a custom class that inherits from UITableView and set your table view to be that class. Then you can create an outlet from that view to your custom class. Like so:
CustomTableView.h
@interface CustomTableView : UITableView
@property (weak, nonatomic) IBOutlet UIView *viewForHeader;
@end
And then the code you were trying to do:
UIView *viewForHeader = [self tableView].viewForHeader;
[[self tableView] setTableHeaderView:viewForHeader]
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.