小编Oli*_*ico的帖子

如何不使用dequeueReusableCellWithIdentifier?

我有一个小表视图,最多可能有10个项目,我不想使用该dequeueReusableCellWithIdentifier方法.原因是,每次我滚动表视图时,我都会有第一行代替最后一行,这需要几秒钟的时间来更新以获得最后一行的更新.

我正在使用原型单元,我尝试删除:

JsonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
Run Code Online (Sandbox Code Playgroud)

但它在表视图中返回空白单元格.

所以这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";

JsonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell=[[JsonTableViewCell alloc]initWithStyle:
          UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
Run Code Online (Sandbox Code Playgroud)

我也试着保持

JsonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
Run Code Online (Sandbox Code Playgroud)

并配置单元格如:

if (cell == nil) {
    cell.title.text = titleStrip;
}
Run Code Online (Sandbox Code Playgroud)

但是在这种情况下,我在故事板中得到了原型单元格.它不是空白,但没有填充数据.

谁能告诉我我做错了什么?

更新****10.10.2014*******

也许所有代码都可以帮助:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return myObject.count;
}

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *CellIdentifier = @"Cell";

    JsonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if …

Run Code Online (Sandbox Code Playgroud)

xcode objective-c uitableview tableview

6
推荐指数
1
解决办法
6000
查看次数

标签 统计

objective-c ×1

tableview ×1

uitableview ×1

xcode ×1