我在运行时创建一个视图并添加一个 UITableView 作为它的子视图。我还将 tableview 的委托定义为 self 。
但是仍然没有调用 UITableView 代表
@interface cViewController : UIViewController
RouteShowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
[RouteShowView setBackgroundColor:[UIColor blueColor]];
table = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, 320, 410) style:UITableViewStylePlain];
table.delegate = self;
UIButton * Go = [UIButton buttonWithType:UIButtonTypeRoundedRect];
Go.frame = CGRectMake(0, 4, 70, 42);
[Go setTitle:@"<< BACK" forState:UIControlStateNormal];
[Go addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
[Go setBackgroundColor:[UIColor blackColor]];
[RouteShowView addSubview:table];
[RouteShowView addSubview:Go];
[self.view addSubview:RouteShowView];