objective-c - 不在绘制时更新 UITableViewDelegate

标签 objective-c ios uitableview

我有一个类定义如下:

@interface ClassViewController : ContentViewController <UITableViewDelegate,
UITableViewDataSource> {
    IBOutlet UITableView* mTableView;
    NSMutableArray *feeds;
    NSMutableData *responseData;
}
@property (nonatomic, retain) UITableView* mTableView;
@property (nonatomic, strong) NSMutableArray* feeds;
@property (nonatomic, strong) NSMutableData* responseData;

我正在尝试在 JSON 请求后加载内容。但是,直到我操作屏幕(例如向下滚动)后,表格才会更新新内容。

我使用[self->mTableView reloadData];没有效果。另外,在:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

我正在设置:

self.mTableView = tableView;

否则结果根本不会传播到表中。

是否有我遗漏的东西,或者应该将 self.mTableView 定义放在其他地方?

我是 Objective-C 和 iOS 开发的新手,所以如果我遗漏了什么,请告诉我。

最佳答案

你应该:

(1) 将mTableView连接到Interface Builder中的表格 View 对象。

(2) 请注意,您可以只使用属性表示法 self.mTableView 而不是 self->mTableView

(1) 将解决您的问题。 (2) 只是一个风格问题(主要)。

enter image description here

关于objective-c - 不在绘制时更新 UITableViewDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13766759/

相关文章:

iphone - 完整整数的两倍

ios - 如何在 objective-c 中打假电话

ios - 首次使用动态链接下载后更新应用程序时未调用 openURL 方法

iOS UITableViewCell cell.imageView 设置圆角

ios - 如何让我的 Facebook GraphAPI 数据在 UITableView 中不重复?

ios - 删除按钮没有出现在 UITableViewCell 中

ios - 将 MKMapView 放在 UITableView 后面

iphone - 如何将音频文件附加到 MFMessage Composer

ios - iOS 中缺少 GTMBase64

ios - AFNetworking for iOS Objective-C 下一次更新