How to add UIView over UITableView in iOS?

I am using the xcode template to create a UITableView application using the UINavigationController.

I need to add a UIView (in a fixed position) between the UINavigationBar and UITableView. How to do it?

Thank.

enter image description here

+5
source share
5 answers

You can do this by setting the UITableView property tableHeaderView.

Link to the UITableView Class

tableHeaderView

Returns the helper view displayed above the table.

@property (non-atomic, save) UIView * tableHeaderView

Discussion The default value is nil. Viewing the table title is different from the section title.

Availability Available in iOS 2.0 and later.

+6

UIView UITableView UIView, , x, y CGRectMake objective-c

+2

UITableview

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
+1

1) , .

@property (, ) IBOutlet UIView * viewHeader;

Setp 2) viewDidLoad

[self.tableview setTableHeaderView: self.viewHeader];

!!!

0

iOS. . , .

This is all theory, I did not do what you want. So do not jerk against me;) This is a friendly offer.

[self.view insertSubview:yourNewView belowSubview:navigationController];

-1
source

All Articles