나는 objective-c를 xcode에 새로 도입 했으므로 바보 같은 질문에 대해 유감스럽게 생각합니다. 내가하고 싶은 것은 id에 따라 이미지를 UITableView의 셀에로드하는 것이다. xml의 모든 객체는 id와 이미지 이름 id id.jpg를가집니다. 나는 그들을 올바르게로드하기 위해 성취했다. 그러나 내가 이미지를 스크롤하면 사라진다. 내가 dequeueReusableCellWithIdentifier와 관련이있는 것처럼 보인 것으로부터 무엇이 발생했는지는 알 수 있지만 그게 무엇인지 알 수는 없습니다. 여기xcode에서 이미지를로드하는 방법?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
theList = [app.listArray objectAtIndex:indexPath.row];
NSString *trimmedString = [theList.t_image stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
cell.imageView.image = [UIImage imageNamed:trimmedString];
cell.textLabel.text = theList.t_name;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if(cell.imageView.image == nil){
cell.imageView.image = [UIImage imageNamed:@"untitled.jpg"];
}
return cell;
}
하고 XML된다 : 어떤 답변
<taxis>
<taxi>
<t_id>1</t_id>
<t_image>1.jpg</t_image>
<t_name>AAA Taxi</t_name>
<t_tel>+42014014</t_tel>
<t_addr>Vodičkova 40</t_addr>
<t_web>www.radiotaxiaaa.cz</t_web>
<t_getin>40</t_getin>
<t_km>26.9</t_km>
<t_wait>5</t_wait>
<t_city>Praha</t_city>
</taxi>
<taxi>
<t_id>2</t_id>
<t_image>2.jpg</t_image>
<t_name>Modrý anděl</t_name>
<t_tel>+420737222333</t_tel>
<t_addr>Cukrovarská 33</t_addr>
<t_web>www.modryandel.cz</t_web>
<t_getin>40</t_getin>
<t_km>19</t_km>
<t_wait>6</t_wait>
<t_city>Praha</t_city>
</taxi>
</taxis>
덕분에 저는 여기에 이미지를로드하는 데 사용하고 코드입니다.
IView * vw = [cell.contentView viewWithTag : 99]의 용도는 무엇입니까? if (vw! = nil) { [vw removeFromSuperview]; } –
없음. 이미이 행을 삭제했습니다. 이전에 시도했던 것의 일부였습니다. – adam
모든 행에 그림이 있습니까? –