【发布时间】:2012-05-07 17:25:11
【问题描述】:
我想在 UIView 中加载 UITableViewController,因为我想更改按钮单击时的视图(如 UITabBar,但使用我自己的按钮)。我正在使用情节提要并定义了一个带有自定义类“InitialTableViewController”和标识符“InitialView”的 TableViewController。
我的代码如下所示:
#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 中创建它后设置值。
标签: ios uitableview uistoryboard