UA-17470720-3

Jump to content


Photo
- - - - -

init of cells


  • Please log in to reply
1 reply to this topic

#1 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 20 April 2013 - 02:51 AM

seems there is a nice quick cellWithText to get a cell going

but sometime i find when building some tables there are lots of times i do
[section addCell:[SCTableViewCell cellWithText:NSLocalizedString(@"Support 1",nil)]];
[section addCell:[SCTableViewCell cellWithText:NSLocalizedString(@"Support 2",nil)]];
[section addCell:[SCTableViewCell cellWithText:NSLocalizedString(@"Support 3",nil)]];
[section addCell:[SCTableViewCell cellWithText:NSLocalizedString(@"Support 4",nil)]];
[section addCell:[SCTableViewCell cellWithText:NSLocalizedString(@"Support 5",nil)]];

ETC...

sometimes these cells might have a detailLabel that needs text.. and sometime a little icon in the imageView

can we have some other inits for cells like


SCTableViewCell cellWithText: withDetailText: withImageViewImage:
that way we could do something like

[section addCell:[SCTableViewCell cellWithText:@"Title Text" withDetailText:nil withImageViewImage:[UIImage imageNamed:@"icon]]];

things like that

?
  • cometlinear likes this

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 29 April 2013 - 08:24 AM

Hi Greg,

Thank you very much for the suggestion, we'll definitely consider adding more initializers like these.

For the time being, you can also easily subclass SCTableViewCell to implement any initializer that you commonly use. For example:

@interface MyCell : SCTableViewCell

+ (id)cellWithText:(NSString *)text detailText:(NSString *)detailText imageViewImage:(UIImage *);
- (id)initWithText:(NSString *)text detailText:(NSString *)detailText imageViewImage:(UIImage *);

@end


@implementation MyCell


+ (id)cellWithText:(NSString *)text detailText:(NSString *)detailText imageViewImage:(UIImage *)image
{
  return [[[self class] alloc] initWithText:text detailText:detailText imageViewImage:image];
}

- (id)initWithText:(NSString *)text detailText:(NSString *)detailText imageViewImage:(UIImage *)image
{
  self = [self initWithText:text];
  if(!self)
    return nil;

  self.detailText = detailText;
  self.imageView.image = image;

  return self;
}

@end





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users