2015-09-15 37 views
-1

,我们可以很容易地从indexPath中的UITableViewCell这样的:如何通过indexPath.row获取uitableViewCell或者仅获取行号而不是indexpath?

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 

而我有的只是行号而不是索引路径,我使用此代码来获取细胞。

NSArray *visible  = [self.tableView indexPathsForVisibleRows]; 
NSIndexPath *indexpath = (NSIndexPath*)[visible objectAtIndex:MyRowNumber]; 
UITableViewCell *tablecell = [self.tableView cellForRowAtIndexPath:indexpath]; 

请告诉我,它是否是一个好评,哪怕不是哪一个。

+1

看到这个链接,可以帮助您http://stackoverflow.com/questions/31649220/detect-button-click-in-table-view-ios-xcode-for-multiple-row-and-section/31649321#31649321 –

回答

1

您可以使用行号创建一个新的NSIndexPath(假设您的表只有一个部分)。

NSIndexPath *indexPath= [NSIndexPath indexPathForRow:yourRowNumber inSection:0]; 
相关问题