Я разрабатываю приложение для iOS, ориентированного на iOS 7.0 и более поздних версий. Теперь, мой вопрос заключается в том, как перезагрузить строки UITableView, которые видны на экране. Я использую динамические ячейки.Перезагрузка Активные ячейки tableview
Фактически при выборе варианта я меняю цвет, как цвет заголовка каждой ячейки, но те ячейки, которые уже загружены на экран, не меняются, и если я загружаю целую таблицу, то это занимает много времени.
Ожидание для вашего ответа.
Код
// по нажатию этой кнопки цвет обновляет
- (IBAction)btnDone:(id)sender {
appDel.selectedMood=_moodDetView.str;
appDel.barColor=_moodDetView.backgroundColor;
self.navigationController.navigationBar.barTintColor = _moodDetView.backgroundColor;
//[self.mainTblView reloadData];
[self.menuView setBackgroundColor:appDel.barColor];
[_moodDetView setHidden:YES];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//For menu contents
if (tableView.tag==2) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.font = [UIFont fontWithName:@"Futura" size:14.0];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.backgroundColor = [UIColor clearColor];
}
switch (indexPath.row) {
case 0:
{
[email protected]"Select Mood";
}
break;
case 1:
{
[email protected]"Search by Author";
}
break;
case 2:
{
[email protected]"Search by Category";
}
break;
case 3:
{
[email protected]"Favorites";
}
break;
case 4:
{
[email protected]"Feeds";
}
break;
default:
break;
}
return cell;
}
//for main table
else{
// Configure the cell...
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
FeedCustomCell* CELL=(FeedCustomCell *)cell;
CELL.cellImageView.layer.cornerRadius=CELL.cellImageView.frame.size.width/2;
CELL.cellImageView.clipsToBounds=YES;
CELL.gesRec=[[CustomTapGestureRecognizer alloc]initWithTarget:self action:@selector(authorBtnTouched:)];
[CELL.lblAuthName setTextAlignment:NSTextAlignmentJustified];
[CELL.lblAuthName setTextColor:[AppDelegate invertColor:appDel.barColor]];
NSString * str=[NSString stringWithFormat:@"%@",[[dataArray objectAtIndex:indexPath.row] objectForKey:@"authorId"]];
UIImage * img=[UIImage imageNamed:str];
CELL.cellImageView.image=img?img:[UIImage imageNamed:@"n3"];
[CELL.lblAuthName addGestureRecognizer:CELL.gesRec];
CELL.gesRec.authorImage=CELL.cellImageView.image;
NSString * authName=[[dataArray objectAtIndex:indexPath.row] objectForKey:@"authorName"];
[CELL.lblAuthName setText:authName];
[CELL.gesRec setAuthorId:(int)str.integerValue];
[CELL.gesRec setAuthorName:authName];
[CELL.txtViewQuote setTextColor:appDel.barColor];
CELL.txtViewQuote.text=[[dataArray objectAtIndex:indexPath.row] objectForKey:@"quoteTxt"];
CGSize sizeThatShouldFitTheContent = [CELL.txtViewQuote sizeThatFits:CELL.txtViewQuote.frame.size];
CELL.heightConstraintOfTxtView.constant = sizeThatShouldFitTheContent.height;
[CELL.contentView sizeToFit];
return CELL;
}
}
С уважением: Сайед Meesum Али
Младший разработчик программного обеспечения
Не могли бы вы показать свой код? Как и одно использование для перезагрузки ячейки, которая не работает, и ': tableView: cellForRowAtIndexPath:'? – Larme
Я не перезагружаю ryt сейчас, как при ее прокрутке он автоматически вносит изменения, поскольку используются повторно используемые ячейки. –
Возможный дубликат [iOS - таблица обновления UITableView правильно?] (Http://stackoverflow.com/questions/7801320/ios-uitableview-refresh-table-properly) – n00bProgrammer