【发布时间】:2014-09-03 08:45:01
【问题描述】:
我正在使用 UITableView 开发 iOS 应用程序。我开始使用 Master-Detail Application 开发应用程序,并使用 StoryBoard。
我想在导航栏和 UITableView 之间插入 320px*100px 的边距。 (导航栏高度为44px。)
我正在写下以下代码。但是边距没有出现。
你能告诉我如何解决这个问题吗?
@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);
}
【问题讨论】:
-
您将 tableView 框架设置为原点 (0,44) 大小 (320,100)。难道你不想 origin (0,144) 给你差距吗?如果是这样,请尝试
CGRectMake(0,144,320,self.tableView.frame.size.height-100) -
如您所指,CGRectMake 的值是错误的,并在上面的代码中编辑为正确的值。但是仍然没有出现边距。
-
@property (strong, nonatomic) IBOutlet UITableView *tableView;最好使用weak用于IBOutlet网点,链接:stackoverflow.com/questions/7678469/… -
我变弱了,但没有变化。
-
尝试为tableview设置
contentInset,[self.tableView setContentInset:UIEdgeInsetsMake(100, 0, 0, 0)];
标签: ios objective-c uitableview uinavigationbar