【发布时间】:2014-01-06 10:33:45
【问题描述】:
我将 UITableView 添加到 Xcode 中的情节提要文件和相应的 .m UIViewController(在属性检查器面板中设置为类类型)。我在 UIViewController 中有一个实例变量 myTableView,我想将它分配给情节提要的 UITableView,以便在代码中调用方法 reloadData。
但是,当我尝试使用 UIViewController 的 NSLog 在 init 或 viewDidLoad 方法中打印出变量信息时,该变量为空。
来自 UIViewController 的示例代码: @property (nonatomic, strong) IBOutlet UITableView *myTableView;
我正在初始化对应的UIViewController如下:
self = [super initWithNibName:@"CorrespondingNibViewControllerName" bundle:nil];
我曾希望 myTableView 实例变量已经通过情节提要初始化为 UITableView 但这似乎没有发生......
【问题讨论】:
-
在你的 .h 文件中为 tableview 添加一个 IBOutlet 并将它连接到你的 xib 文件中。
标签: ios objective-c xcode uitableview uistoryboard