2014-03-19 3 views
1

customCell이 있고 셀에 버튼을 추가했습니다.수퍼 뷰를 이해하는 방법

SettingTableViewCell * cell = (SettingTableViewCell *)[[sender superview] superview]; 
NSIndexPath * path = [self.tableView indexPathForCell:cell]; 

두 번째 문장을 이해하는 방법!

대단히 감사합니다!

+0

두 번째 문장은 현재 셀의 get [indexPath (about indexPath)] (http://stackoverflow.com/questions/14765730/nsindexpath-item-vs-nsindexpath-row/14765781#14765781)에 사용됩니다. – iPatel

답변

1

뭘 하려는지 모르겠다. 그러나 나는이 두 줄에 대한 설명을한다.

[sender superview] 즉, 버튼을 클릭하면 해당 셀의 contentview에 배치 된 sender이 표시됩니다. 그럼 다시 superview] 전화, 그래서 당신은 세포에 superview of content view 얻을 수 있습니다. 해당 뷰 계층 구조를 참조하십시오.

----cell 
-------ContentView 
-------------Sender 

NSIndexPath * path = [self.tableView indexPathForCell:cell];. 이 줄은 tableview 셀 스택에 보관되는 해당 셀에 대해 indexPath를 제공합니다.

+0

예, 알겠습니다! 나는 그들 사이의 계급 관계를 이해하지 못합니다. 고맙습니다! –

+0

셀에는 하위보기로 내용보기가 있고 내용보기에는 하위보기로 단추가 있습니다. 뷰 계층 구조에 있습니다. 뷰 계층 구조에 대한 자세한 내용은이 링크를 참조하십시오. https://developer.apple.com/library/ios/documentation/windowsviews/conceptual/viewpg_iphoneos/CreatingViews/CreatingViews.html – Mani

+0

customCell - (id) initWithStyle : (UITableViewCellStyle) 스타일 reuseIdentifier : (NSString *) reuseIdentifier [self addSubview :] 및 [self.contentView addSubview] 둘의 차이점은 무엇입니까? –

관련 문제