2013-08-12 4 views
-1

Я установил пользовательскую ячейку UITableView и хотел бы получить доступ к ее свойствам в методе didSelectRowAtIndexPath:. Однако следующий код, который я использую, не позволяет мне получить доступ к его свойствам (метки, текстовые поля и т. Д.). Я также разместил свой cellForRowAtIndexPath: для справки.Как определить пользовательский UITableViewCell?

UITableViewCell *cell = [self.setupTable cellForRowAtIndexPath:indexPath]; 

Вот код, я использую в didSelectRowAtIndexPath:, вот cellForRowAtIndexPath:.

- (UITableViewCell *)tableView:(UITableView *)tableView 
     cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"SetupCellID"; 

    SetupCell *cell = (SetupCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) 
    { 
     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SetupCell" owner:self options:nil]; 
     cell = [nib objectAtIndex:0]; 
    } 

    cell.accessoryType = UITableViewCellAccessoryCheckmark; 
    cell.setupFeedName.text = [self.setupFeeds objectAtIndex:indexPath.row]; 

    return cell; 
} 

Любая помощь приветствуется!

+0

Вы можете разместить файл заголовка вашего 'SetupCell' класса. –

ответ

3
////Use LIke this 
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
    SetupCell *cell=(SetupCell*)[tableView cellForRowAtIndexPath:indexPath]; 
    cell.setupFeedName.text [email protected]"Hari kishan"; 
    } 
+0

Не могли бы вы помочь мне в моем другом вопросе? http://stackoverflow.com/questions/18186854/selecting-cells-and-moving-them-to-a-separate-array –

+0

Я отправил ответ там >>> см., что >> –

0

Проверьте эту ссылку below. Это самый простой, который я нашел до сих пор.

вам нужно заменить код ниже в методе cellForRowAtIndexPath.

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
} 

С помощью этого кода

mycustomCell *cell = (mycustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[mycustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
} 
+0

Не могли бы вы помочь мне в моем другой вопрос? http://stackoverflow.com/questions/18186854/selecting-cells-and-moving-them-to-a-separate-array –

Смежные вопросы