Get Selected index of UITableView

前端 未结 5 2013
忘了有多久
忘了有多久 2020-12-04 16:09

I want to have selected index for UITableView. I have written following code:

NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0];
         


        
5条回答
  •  -上瘾入骨i
    2020-12-04 16:56

    Get current selected row. May be helpful if you have only one section.

    - (NSUInteger)currentSellectedRowIndex
    {
        NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
        if (selectedIndexPath) {
            return selectedIndexPath.row;
        }
        else {
            return NSNotFound;
        }
    }
    

提交回复
热议问题