2014-09-20 71 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)]; 
相关问题