从“子视图”调用 UIViewController
我有一个 UIViewController,当它加载时,它会加载这个..
MapViewController *mapController = [[MapViewController alloc] initWithNibName:@"MapView" bundle:nil];
self.mapViewController = mapController;
[self.view insertSubview:mapController.view atIndex:0];
[mapController release];
我还有一个切换视图按钮,可以更改为表视图....
if (self.tableViewController ==nil)
{
TableViewController *tableController = [[TableViewController alloc] initWithNibName:@"TableView" bundle:nil];
self.tableViewController = tableController;
[tableController release];
//[self.view insertSubview:detailController atIndex:0];
}
if (self.mapViewController.view.superview == nil)
{
[tableViewController.view removeFromSuperview];
[self.view insertSubview:mapViewController.view atIndex:0];
}
else
{
[mapViewController.view removeFromSuperview];
[self.view insertSubview:tableViewController.view atIndex:0];
}
我试图根据在中选择一行将视图更改为详细视图表视图,我根本不知道如何调用它。 我所有的方法似乎都失败了! 请帮忙!
I have a UIViewController which when it loads it loads up this..
MapViewController *mapController = [[MapViewController alloc] initWithNibName:@"MapView" bundle:nil];
self.mapViewController = mapController;
[self.view insertSubview:mapController.view atIndex:0];
[mapController release];
I also have a switch views button that can change to a table view....
if (self.tableViewController ==nil)
{
TableViewController *tableController = [[TableViewController alloc] initWithNibName:@"TableView" bundle:nil];
self.tableViewController = tableController;
[tableController release];
//[self.view insertSubview:detailController atIndex:0];
}
if (self.mapViewController.view.superview == nil)
{
[tableViewController.view removeFromSuperview];
[self.view insertSubview:mapViewController.view atIndex:0];
}
else
{
[mapViewController.view removeFromSuperview];
[self.view insertSubview:tableViewController.view atIndex:0];
}
I am trying to change the view to a detail view based on selecting a row in the table view and I cannot work out how to call it at all. All methods I have seem to fail! Please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 UITableViewDelegate 协议添加到您的控制器类中。
当您创建表视图控制器时,使用以下方法将其委托设置为您的控制器:
在您的 tableViewController 中,实现 didSelectRowAtIndexPath:
Add the UITableViewDelegate protocol to your controller class.
When you create your table veiw controller set its delegate to be your controller using:
In your tableViewController, implement didSelectRowAtIndexPath:
您应该查看用于处理行选择的类是 UITableViewDelegate,它具有以下方法:
The class you should look at for handling row selection is UITableViewDelegate, which has the method: