Get the UItableViewCell Contentview Programmettically using the section and index
I need to get开发者_运维技巧 the specific uitableviewcell contentview using the row and index of the cell in the tableview?
I tried the below code but it is not working:
NSIndexPath *nowIndex = [NSIndexPath indexPathForRow:rowNo inSection:sectionNo];
UITableViewCell *cell = (UITableViewCell *)[mytableview cellForRowAtIndexPath:nowIndex];
If you look at cellForRowAtIndexPath
,
An object representing a cell of the table or nil if the cell is not visible or indexPath is out of range.
It's likely that the cell at nowIndex
isn't visible.
I'm guessing there's a better way to do what you're trying to do. Since you're obviously loading the content of the cell from somewhere why not just access that?
i.e. If you're trying to get the state of a cell subview, you should have that object in your class header (not just instantiated in cellForRowInIndexPath). Then you can access the value from anywhere within the class.
精彩评论