繁体   English   中英

更新didUpdateLocation中的headerView

[英]Update headerView in the didUpdateLocation

嗨,我有以下代码:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    static NSString *LocationHeaderCellIdentifier = @"Location Header Cell";

    LocationHeaderCell *locationHeaderCell;
    locationHeaderCell = (LocationHeaderCell *)[tableView dequeueReusableCellWithIdentifier:LocationHeaderCellIdentifier];
    locationHeaderCell.lblCurrentAddress.text = self.currentAddress;

    return locationHeaderCell;
}

你们可以看到,我使用原型单元格作为标题。 我要完成的工作是访问didUpdateLocation委托中的此标头以更改标签(刷新标签)。 我不想使用[reload data]因为我从不同的Web服务器收到两个不同的响应。 一个来自Parse,另一个来自Apple。 因此,我不知道哪个会先出现。 我尝试检索标题视图,并显示Null。

有什么建议么?

您可以在属性中保留对此LocationHeaderCell的引用,例如:

@property(nonatomic, strong) LocationHeaderCell *myHeader;

并像这样修改您的代码:

if (self.myHeader==nil)
    self.myHeader = (LocationHeaderCell *)[tableView dequeueReusableCellWithIdentifier:LocationHeaderCellIdentifier];

因此,在didUpdateLocation只需执行self.myHeader.lblCurrentAddress.text = @whatever";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM