supermonkey
supermonkey

Reputation: 655

Insert margin between navigation bar and UITableView

I am developing iOS App with UITableView. I begin to develop the App with Master-Detail Application and I use StoryBoard.

I would like to insert 320px*100px margin between navigation bar and UITableView. (Height of navigation bar is 44px.)

I am writing down the following code. However margin doesn't appear.

Could you tell me how to solve this problem?

@interface MasterViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (strong, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation MasterViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.frame = CGRectMake(0, 144, 320, self.view.frame.size.height);

}

Upvotes: 0

Views: 164

Answers (1)

Alex Peda
Alex Peda

Reputation: 4290

This your line:

self.tableView.frame = CGRectMake(0, 44, 320, 100);

100 sets tableView height to 100 instead of margin. Try following please:

self.tableView.frame = CGRectMake(0, 44 + 100, 320, self.view.frame.size.height - 44 - 100);

Upvotes: 2

Related Questions