में दिखाता है मैंने इंटरफेस बिल्डर (स्टोरीबोर्ड) में एक कस्टम UITableViewCell
बनाया और #import CustomTableViewCell.h
के माध्यम से इसे अपने प्रोजेक्ट में आयात किया।कस्टम UITableViewCell (आईबी) केवल चयनित राज्य
सबकुछ ठीक काम करता है, लेकिन सेल केवल चयनित राज्य में लोड होता है।
मैं सेल init द्वारा प्रत्येक पंक्ति में लोड किया जा करना चाहते हैं।
पीएस स्लाइडर और टेक्स्ट फ़ील्ड कनेक्शन ठीक काम करते हैं। मैंने सभी आईबी कनेक्शन भी बनाए।
CustomTableViewCell.m
#import "CustomTableViewCell.h"
@implementation CustomTableViewCell
@synthesize sliderLabel, slider;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (IBAction)getSliderValuesWithValue:(UISlider *)sender
{
sliderLabel.text = [NSString stringWithFormat:@"%i/100", (int) roundf(sender.value)];
}
@end
Further Code
- (CustomTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Kriterium";
CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
cell.textLabel.text = [NSString stringWithFormat:@"%@", [listOfItems objectAtIndex:indexPath.row]];
return cell;
}
पी.एस. अगर मैं उपरोक्त विधि में कुछ बटन आदि प्रोग्रामेटिक रूप से जोड़ता हूं तो यह काम करता है। लेकिन मैं आईबी में पंक्तियों को डिजाइन करना चाहता हूं। एक समाधान होना है।
क्या आप पंक्तियों के साथ UITableView को पॉप्युलेट करते समय अपने सेलफॉररोएट इंडेक्सपैथ विधि के लिए कोड पोस्ट कर सकते हैं? – reddersky
मैंने अपना जवाब अपडेट किया। – DAS
क्या आपने इस सेल को स्टोरीबोर्ड में टेबल व्यू के भीतर एक अलग निब में या प्रोटोटाइप के रूप में डिज़ाइन किया है? – jrturton