Reputation: 7227
I am using the xcode template to create a UITableView application with UINavigationController.
I need to add a UIView (at fixed position) between the UINavigationBar and the UITableView. How to do that ?
Thanks.
Upvotes: 5
Views: 2922
Reputation: 57
Step 1) Create a header view as, set outlet to that view.
@property(nonatomic,strong)IBOutlet UIView *viewHeader;
Setp 2) Add following single line code on viewDidLoad
[self.tableview setTableHeaderView:self.viewHeader];
Done!!!
Upvotes: 0
Reputation: 19
you need to implement following UITableview delegate methods
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
Upvotes: 1
Reputation: 73588
Views are maintained in a hierarchy in iOS. They are maintained essentially as an array with the latest view first. To insert some view below one view or above another you just need to manipulate this.
All this is theory, I have not done what you want. So dont hold a grudge against me ;) this is a friendly suggestion.
[self.view insertSubview:yourNewView belowSubview:navigationController];
Upvotes: -1
Reputation: 4196
You can do this by setting the UITableView's tableHeaderView
property.
tableHeaderView
Returns an accessory view that is displayed above the table.
@property(nonatomic, retain) UIView *tableHeaderView
Discussion The default value is nil. The table header view is different from a section header.
Availability Available in iOS 2.0 and later.
Upvotes: 6
Reputation: 4835
Add UIView and UITableView as subviews of UIView and then position their height, width and x, y position from the Size Inspector in Interface builder or Use CGRectMake
in objective-c
Upvotes: 2