</pre><img src="https://img-blog.csdn.net/20160121165359319?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px"></span><p></p><p></p><p>如图:</p><p>然后将其IBOut和控制器关联(container)</p><p></p><pre code_snippet_id="1561229" snippet_file_name="blog_20160121_2_4827446" name="code" class="objc"> //下方公号列表放在container容器里,直接在该容器里的tableviewcontroller设置值
    [threeView addSubview:self.tableViewContainer];
    self.tableViewContainer.frame = CGRectMake(0, 0, 300, 400);


最后可以再设置其大小:

-(void)viewDidLayoutSubviews
{
    self.tableViewContainer.frame = CGRectMake(0, 38, SCREEN_WIDTH, threeView.frame.size.height-38);
}

最近使用Container View来在主View Controller建立自己的子Controller,可是遇到问题,不知道如何用代码获取Controller View附带的View Controller。 

本想获取了其附带的View Controller,在里面设置代理,然后再主View Controller中实现代理方法,找了很多资料,解决方案如下。 


建立一个.h与.m文件,使其关联Container view附带的View Controller,在里面设置代理。 

  1. 点击Segue,设置Identifier 
  2. 在主View Controller中继承方法 
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
实现下面代码即可。 

这样就可以获取到segue跳转的View Controller的Controller,然后给其设置代理便可以相互调用。



Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐