我創建按以下方式定製的細胞我錯過了什麼使我的自定義UITableView單元格工作?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
FacilityResult* currentResult = [_facilityResults objectAtIndex:indexPath.row];
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"facilityResultDesign" forIndexPath:indexPath];
}
return cell;
}
當創建FacilityResult對象,它是自定義小區我更新標籤如下類:
@implementation FacilityResult
- (id)initWithModel:(NSString *)name city:(NSString*)city zipcode:(NSString*)zipcode facility_id:(NSString*)facility_id{
_name = name;
_zipcode = zipcode;
_city = city;
_facility_id = facility_id;
return self;
}
- (id)initwithModel:(NSMutableDictionary*)propertyDictionary{
if (![[propertyDictionary allKeys] containsObject:@"name"])
NSLog(@"Error: Cell Object does not have a name");
else{
_name = propertyDictionary[@"name"];
[propertyDictionary removeObjectForKey:@"name"];
[_nameField setText:_name];
}
if (![[propertyDictionary allKeys] containsObject:@"city"])
NSLog(@"Error: Cell Object does not have a city");
else{
_city= propertyDictionary[@"city"];
[propertyDictionary removeObjectForKey:@"city"];
[_cityField setText:_city];
}
return self;
}
@end
- 更新viewDidLoad中
- (void)viewDidLoad{
[super viewDidLoad];
[[login getSearchFacility] setDelegate:self];
[_resultTable registerNib:[UINib nibWithNibName:@"FacilityRow" bundle:nil] forCellReuseIdentifier:@"facilityResultDesign"];
if(_facilityResults==nil)
_facilityResults = [[NSMutableArray alloc] init];
}
然而,標籤不更新「有些公司的」細胞是我對Xcode的標籤輸入的默認名稱。它應該更新爲name1。
請按xib編輯器上的按鈕「顯示文檔大綱」顯示所有樹形視圖 – stosha 2014-08-31 06:27:30