2014-09-20 72 views
0

我想在我的UITableViewController中添加一個子視圖。我想要的是,當用戶點擊一個導航欄項目,一個小窗口或一個子視圖時,將顯示其中包含兩個按鈕。當用戶點擊任何按鈕時,子視圖將消失。我甚至沒有成功在我的TableViewController中添加子視圖。我加入viewDidLoad中以下代碼:在UITableViewController中添加UIView作爲子視圖(或向上滑動菜單)

UIView* simpleView = [[UIView alloc] initWithFrame:CGRectMake(0,200,300,100)]; 

UIButton* add= [[UIButton alloc] initWithFrame:CGRectMake(0,240,300,100)]; 
[email protected]"here"; 
[simpleView addSubview:add]; 
[self.tableView addSubview:simpleView]; 

,沒有工作,錯誤的是 「的setValue:forUndefinedKey:]:此類不是密鑰值編碼兼容的關鍵viewReference'。」 我改變[self.view addSubview:simpleView]; ,它仍然沒有工作

有人可以告訴我如何添加一個子視圖在UITableViewController並提供一些示例代碼?

謝謝

回答

0

你的按鈕框架矩形是不正確的,所以你的simpleView是完全透明的。更改

UIButton* add= [[UIButton alloc] initWithFrame:CGRectMake(0,240,300,100)]; 

UIButton* add= [[UIButton alloc] initWithFrame:CGRectMake(0, 40,300,100)]; 
相關問題