不在绘制时更新UITableViewDelegate

时间:2012-12-07 16:10:32

标签: 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 个答案:

答案 0 :(得分:1)

你应该:

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

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

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

enter image description here