This should work but it's giving me a warning.
I'm making a custom table cell with a textfield in it.
Code:
TextInput.h
@interface TextInput : UITableViewCell <UITextFieldDelegate> {
}
I want to pass in a string into the textfield if there is any so I created an extra param 'contentLable'
Code:
TextInput.m
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier contentLable:(NSString *)contentLable
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
UITextField *text = [[UITextField alloc] initWithFrame:CGRectMake(10.0, 10.0, 280.0, 30.0)];
text.returnKeyType = UIReturnKeyDone;
text.delegate = self;
//text.borderStyle = UITextBorderStyleRoundedRect;
text.autocorrectionType = UITextAutocorrectionTypeNo;
text.clearButtonMode = UITextFieldViewModeWhileEditing;
text.text = contentLable;
[self.contentView addSubview:text];
}
return self;
}
But when I want to alloc init this it's giving me a warning (Method '-initWithStyle:reuseIdentifier:contentLable' not found (return type default to id)
Code:
if (indexPath.row == 0) {
cell = [[[TextInput alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier contentLable:@"Some text"] autorelease];
cell.textLabel.text = @"Name";
}
Any ideas?
thanks.