में प्रत्येक अनुभाग के लिए अलग-अलग कस्टम सेल का उपयोग करें, मुझे मेरी तालिका पर कुछ अजीब लगता है। मैं दो या दो से अधिक अनुभाग के साथ टेबल बनाना चाहता हूं, और पहले खंड पर मैं दूसरों के साथ अलग-अलग कस्टम सेल का उपयोग करना चाहता हूं।UITableView
तो मैं पहले खंड पर मेरी tableView:cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cell";
if (indexPath.section == 0) {
// cell for section one
HeaderCell *headerCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(!headerCell) {
[tableView registerNib:[UINib nibWithNibName:@"HeaderCell" bundle:nil] forCellReuseIdentifier:cellIdentifier];
headerCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
}
headerCell.labelName.text = @"First Section";
return headerCell;
}
else {
// Cell for another section
DetailCell *detailCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!detailSection) {
[tableView registerNib:[UINib nibWithNibName:@"DetailCell" bundle:nil] forCellReuseIdentifier:cellIdentifier];
detailCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
}
detailCell.textLabel.text = @"Another Section Row";
return detailCell;
}
}
पर इस बनाया है, मैं अपने पंक्ति के लिए headerCell
उपयोग करने के लिए है, तो दूसरों पर detailCell
का उपयोग करना चाहते हैं। यह कोड काम करता है लेकिन सेक्शन दो की पंक्ति पर headerCell
"detailCell
" के तहत अभी भी उपयोग की तरह दिखता है। मैंने headerCell.xib
में लेबल जोड़ा, और यह अभी भी detailCell
पर दिखाया गया है। यह image देखें।
मुझे यह सब लगता है क्योंकि मैं सभी अनुभागों के लिए एक सेल पहचानकर्ता का उपयोग करता हूं। किसी के पास समाधान है? बहुत बहुत धन्यवाद।
हाँ, आप 2 अलग सेल पहचानकर्ता का उपयोग करने की आवश्यकता है। – Gandalf