Ошибка с UITableView iphone - PullRequest
       36

Ошибка с UITableView iphone

3 голосов
/ 18 мая 2011

у меня есть UITableView со строками

-[self.friendsPhotoArray count]+1

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.friendsPhotoArray count]+1;
    NSLog(@"array val%@",[self.friendsPhotoArray count]);

}

Теперь я хочу проверить, какая строка является последней, и сделать ее недоступной для редактирования, т.е. не выполнять didSelect функция. Может кто-нибудь помочь?

Спасибо.

Ответы [ 6 ]

1 голос
/ 18 мая 2011
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  if(indexPath.row==[array count]-1)
  {
    //Do Nothing
  }
  else 
  {
    //Do Whatever You Want
  }
}
0 голосов
/ 12 января 2015
-(UITableViewCellEditingStyle)tableView:(UITableView *)aTableView  editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath

{

    if (indexPath.row==yourarray.count-1)
    {
        return UITableViewCellEditingStyleNone;
    }
    else
    {
        return UITableViewCellEditingStyleDelete;
    }
}
0 голосов
/ 18 мая 2011
if (indexPath.row ==  [array count]+1) {

    [cell setUserInteractionEnabled:NO];

}
0 голосов
/ 18 мая 2011

сделайте это как 2 раздела и попробуйте ... результат может иногда создавать проблемы .. сделайте один раздел, который вам нужен выбор, и другой раздел, чтобы не выбирать

0 голосов
/ 18 мая 2011

В вашем cellForRowAtIndexPath методе просто поставьте следующую проверку:

if (indexPath.row ==  [self.friendsPhotoArray count]+1) {

[cell setUserInteractionEnabled:NO];

}
0 голосов
/ 18 мая 2011

Чтобы отключить выбор для последней строки представления таблицы:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    // make the cell selection style none 
    }
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    // if the last row is selected do nothing.
       if(row!=count+1){
           // do functionality
       }
  }
...