Я использую UITableView
для отображения элементов array
. В UITableViewCell
я использовал число UILabels
и UIButtons
для выполнения действий. Все отображается хорошо, но проблема возникает, когда я пытаюсь scroll
TableView
, как, когда я начинаю прокручивать каждый раз, когда Images
n Labels
меняет свою позицию индекса. Это первый раз, когда я сталкиваюсь с такой проблемой. Я также прошел через много решений по SO, но проблема остается той же.
Я делюсь своим кодом:
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SimpleTableItem"];
}
cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
NSString* fromDate = [[eventArray objectAtIndex:indexPath.row]valueForKey:@"StartDateTime1"];
UILabel * nameLbl = (UILabel *)[cell viewWithTag:101];
nameLbl.text = fromDate;
//First Column
NSString* titleStr = [[eventArray objectAtIndex:indexPath.row]valueForKey:@"Name1"];
//NSLog(@"%@",spk_about);
UILabel * spk_aboutLbl = (UILabel *)[cell viewWithTag:102];
spk_aboutLbl.text = titleStr;
NSString* Description = [[eventArray objectAtIndex:indexPath.row]valueForKey:@"Description1"];
NSLog(@"%@",Description);
UILabel * DescriptionLbl = (UILabel *)[cell viewWithTag:103];
DescriptionLbl.text = Description;
NSString* ID = [[eventArray objectAtIndex:indexPath.row]valueForKey:@"ID1"];
//NSLog(@"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=%@",compStr);
UILabel * IDStrLbl = (UILabel *)[cell viewWithTag:104];
IDStrLbl.text = ID;
NSString * eventStatus = [[eventArray objectAtIndex:indexPath.row]valueForKey:@"Status1"];
NSLog(@"eventStatus is ..................................................%@",eventStatus);
UILabel * eventStatusLbl = (UILabel *)[cell viewWithTag:113];
eventStatusLbl.text = eventStatus;
rsvpbtn = (UIButton *)[cell viewWithTag:111];
[rsvpbtn addTarget:self action:@selector(ShowRSVP:) forControlEvents:UIControlEventTouchUpInside];
[rsvpbtn setTintColor:[UIColor blackColor]];
rsvpbtn.tag = indexPath.row;
mapButton = (UIButton *)[cell viewWithTag:112];
[mapButton addTarget:self action:@selector(ShowMap:) forControlEvents:UIControlEventTouchUpInside];
[mapButton setTintColor:[UIColor blackColor]];
mapButton.tag = indexPath.row;
//131
tickButton1 = (UIButton *)[cell viewWithTag:131];
[tickButton1 addTarget:self action:@selector(tickDetail1:) forControlEvents:UIControlEventTouchUpInside];
[tickButton1 setTintColor:[UIColor blackColor]];
tickButton1.tag = indexPath.row;
if ([eventStatus isEqualToString:@"0"])
{
rsvpbtn.hidden = true;
tickButton2.hidden = true;
}
else if ([eventStatus isEqualToString:@"1"])
{
tickButton1.hidden = true;
rsvpbtn.hidden = false;
}
else if ([eventStatus isEqualToString:@"2"])
{
rsvpbtn.hidden = true;
tickButton1.hidden = false;
}
else if ([eventStatus isEqualToString:@""])
{
rsvpbtn.hidden = true;
mapButton.hidden = true;
tickButton1.hidden = true;
}
return cell;
}
мой JSON
Array
ответ:
{
"ID1": "11",
"Name1": "Registration",
"Description1": "",
"StartDateTime1": "8:00 AM",
"EndDateTime1": "8:30 AM",
"AgendaMapLink1": "",
"Capacity1": "",
"AgendaMap1": "",
"RSVP1": "",
"TotalGuest1": "1",
"Status1": "2",
"ID2": "",
"Name2": "",
"Description2": "",
"StartDateTime2": "",
"EndDateTime2": "",
"AgendaMapLink2": "",
"Capacity2": "",
"AgendaMap2": "",
"RSVP2": "",
"TotalGuest2": "",
"Status2": "",
"ID3": "",
"Name3": "",
"Description3": "",
"StartDateTime3": "",
"EndDateTime3": "",
"AgendaMapLink3": "",
"Capacity3": "",
"AgendaMap3": "",
"RSVP3": "",
"TotalGuest3": "",
"Status3": "",
"ID4": "",
"Name4": "",
"Description4": "",
"StartDateTime4": "",
"EndDateTime4": "",
"AgendaMapLink4": "",
"Capacity4": "",
"AgendaMap4": "",
"RSVP4": "",
"TotalGuest4": "",
"Status4": "",
"ID5": "",
"Name5": "",
"Description5": "",
"StartDateTime5": "",
"EndDateTime5": "",
"AgendaMapLink5": "",
"Capacity5": "",
"AgendaMap5": "",
"RSVP5": "",
"TotalGuest5": "",
"Status5": ""
},