我可以在界面構建器中的現有視圖中添加一個tableview。我可以使用其他控件將視圖添加到視圖嗎?
我的接口生成器看起來像下面
但是,當我在模擬器中運行的代碼,你可以看到,因爲它覆蓋的按鈕表中沒有在同一個地方顯示爲界面生成器在底部 ???
更新中...我有點取得進展,但在底部的按鈕被隱藏?
固定...與您所附加的建議如下面的代碼:)
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 40)];
view.backgroundColor = [UIColor whiteColor];
UIButton *buttonA = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buttonA.frame = CGRectMake(101,5,118,29);
[buttonA setTitle:@"Save & Exit" forState:UIControlStateNormal];
buttonA.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[view addSubview:buttonA];
UIButton *buttonB = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buttonB.frame = CGRectMake(254,5,56,29);
[buttonB setTitle:@"Next" forState:UIControlStateNormal];
buttonB.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[view addSubview:buttonB];
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 40;
}
可能是因爲自動對齊。 – KingofBliss 2013-02-27 09:28:17
不確定,但檢查自動調整您的tableview。 – 2013-02-27 09:36:09
是的你可以,並猜測你已經做了什麼:)。休息只是解除底部並在你的tableView中添加streaching。 – rptwsthi 2013-02-27 09:46:12