我想加载一个UITableViewController一个UIView里面,因为我想改变按钮,点击视图(如UITabBar,但我自己的按钮)。我使用的是故事板,并已定义的自定义类“InitialTableViewController”一TableViewController和标识符“InitialView”。负载的UITableViewController编程,并添加视图作为子视图
我的代码如下所示:
#import "MyViewController.h"
#import "InitialTableViewController.h"
@interface MyViewController()
@end
@implementation MyViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
InitialTableViewController *tableControl = [self.storyboard instantiateViewControllerWithIdentifier:@"InitialView"];
[[self view] addSubview:[tableControl view]];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
@end
的观点开始,我可以看到我的表,但“InitialTableViewController”里面的代码无法正常工作。
我能做些什么?
我认为你需要的地方保留'tableControl'实例。对'MyViewController'一个属性,您在viewDidLoad中创建后设置的值。 – adig