我想在 FAQViewcontroller 中重新加载一些数据。 tableview放在 nib文件(视图)中,该文件加载了Viewcontroller,这种方式称为:
FAQViewController *vc = [[FAQViewController alloc] initWithNibName:@"FAQViewController" bundle:nil];
[self presentViewController:vc animated:YES completion:nil];
在FAQView控件的viewDidLoad中,tableview以正确的方式显示(我看到分隔线,当我改变backgroundColor时,它运行良好)。但是还没有信息要显示,所以单元格是空的(正如预期的那样)。
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.tableView registerNib:[UINib nibWithNibName:@"FAQCell" bundle:nil] forCellReuseIdentifier:@"FAQCell"];
if (self.faqData == nil || [_faqData count] == 0) {
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
[[DataModel sharedInstance] getFrequentlyAskedQuestions:^(NSError *error) {
}];
});
}
}
网络调用完成后,FAQView控制器中的此功能称为:
- (void)setFaqData:(NSArray *)faqData {
_faqData = faqData;
NSLog(@"%@", _faqData);
dispatch_async(dispatch_get_main_queue(), ^() {
[self.tableView reloadData];
});
}
但是reloadData什么也没做。没有人参与其中的数字。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _faqData.count;
}
我不知道该怎么做。从来没有这个(通常我在Swift中编码,也许我忘了Objective-C中的东西)?
有谁知道我做错了什么?
非常感谢!
答案 0 :(得分:0)
你能尝试将tableView作为强引用吗? 类似的东西:
@property (nonatomic, strong) IBOutlet UITableView *tableView