एक और तरीका है एक कस्टम सेल बना सकते हैं और layoutSubviews
विधि ओवरराइड करने के लिए है।
@interface CustomCell : UITableViewCell
@end
@implementation CustomCell
- (void)layoutSubviews
{
[super layoutSubviews];
// grab bound for contentView
CGRect contentViewBound = self.contentView.bounds;
// grab the frame for the imageView
CGRect imageViewFrame = self.imageView.frame;
// change x position
imageViewFrame.origin.x = contentViewBound.size.width - imageViewFrame.size.width;
// assign the new frame
self.imageView.frame = imageViewFrame;
}
@end
कि Rembember cellForRowAtIndexPath
में आप बना सकते हैं और CustomCell
और नहीं UITableViewCell
पुन: उपयोग करने की जरूरत है।
उम्मीद है कि यह मदद करता है।
संपादित
#import "CustomCell.h"
// other code here...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
return cell;
}
स्रोत
2012-02-25 16:48:36
मैं डर लग रहा है आप के साथ standar 'नहीं कर सकते UITableViewCell' आपको अपने सेल का उपयोग करना होगा और फिर इसे अनुकूलित करना होगा। – HelmiB