यदि आप अपनी समस्या के लिए कुछ अन्य समाधान ढूंढ रहे हैं, तो मैं आपको एक कस्टम सेल प्रोग्रामेटिक रूप से बनाने का सुझाव दूंगा।
मैं आपको चरण-दर-चरण समझा रहा हूं, इससे आपको बेहतर मदद मिलेगी।
तो इसके लिए UITableViewCell
से प्राप्त एक वर्ग बनाएं, और अपने टैबलेटसेल में आवश्यक घटकों को जोड़ें।
इसलिए आपकी .h फ़ाइल इस तरह दिखती है।
// -------- स्टार्ट ------- >>
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell{
UIButton *btn1;
UIButton *btn2;
UIButton *btn3;
}
@property(nonatomic , retain) UIButton *btn1;
@property(nonatomic , retain) UIButton *btn2;
@property(nonatomic , retain) UIButton *btn3;
@end
// ------- अंत ------- < <
और आपका।मीटर फ़ाइल इस
// -------- स्टार्ट ------- >> तरह दिखेगा
#import "CustomCell.h"
@implementation CustomCell
@synthesize btn1, btn2, btn3;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
//----frame the components as per your project req.----
btn1 = [[UIButton alloc] initWithFrame:CGRectMake(1, 1, 85, 70)];
[self.contentView addSubview:btn1];
btn2 = [[UIButton alloc] initWithFrame:CGRectMake(100, 1, 85, 70)];
[self.contentView addSubview:btn2];
btn3 = [[UIButton alloc] initWithFrame:CGRectMake(195,1, 85, 70)];
[self.contentView addSubview:btn3];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
// -------- अंत- ------ < <
अब आप अपने अन्य वर्गों में इस कस्टम सेल का पुन: उपयोग करने के लिए तैयार हैं। और आवश्यकता के अनुसार उन्हें संशोधित भी कर सकते हैं।
cellForRowAtIndexPath में अब >>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
}
[cell.btN1 setImage:[UIImage imageNamed:@"YOUR IMAGE NAME"] forState:UIControlStateNormal]; // YOU CAN MAKE CHANGES HERE.
................// remaining logic goes here
return cell;
}
आशा है कि यह तुम्हारी मदद करेगा।
1 .Also take a look on link tutorial.
2. A Closer Look at Table View Cells
जबकि OO संदर्भ में सोच, मैं दोहराव से बचने की कोशिश कर रहा था है, – Ans