It seems it can't be done without a custom cell class. Because we don’t have a storyboard prototype cell to manipulate graphically for the filtered table view, we have to programmatically create the cells. And for that we need a custom cell class and with initWithStyle: method in the .m file as follows.
So I created a class called SelectionCell subclass of UITableViewCell, and in IB assigned custom cell class to SelectionCell class and create IBOutlet for all UI controls in my custom cell into SelectionCell.h file
@interface SelectionCell : UITableViewCell{
}
@property (strong, nonatomic) IBOutlet UIImageView *contactPictureID;
@property (strong, nonatomic) IBOutlet UILabel *contactName;
@property (strong, nonatomic) IBOutlet UILabel *emailAddress;
@property (strong, nonatomic) IBOutlet UIImageView *selectedEmailState;
@end
in initWithStyle: method, I had to recreate all the UI controls programmatically and add them to the contentView as subviews:
// SelectionCell.m
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.selectionStyle = UITableViewCellSelectionStyleNone;
_contactPictureID = [[UIImageView alloc] initWithFrame:(CGRectMake(10, 14, 48, 48))];
_contactName = [[UILabel alloc] initWithFrame:(CGRectMake(66, 14, 201, 30))];
_contactName.font = [UIFont boldSystemFontOfSize:20];
_contactName.textAlignment = NSTextAlignmentLeft;
_emailAddress = [[UILabel alloc] initWithFrame:(CGRectMake(66, 41, 201, 21))];
_emailAddress.font = [UIFont systemFontOfSize:16];
_emailAddress.textAlignment = NSTextAlignmentLeft;
_selectedEmailState = [[UIImageView alloc] initWithFrame:(CGRectMake(275, 22, 32, 32))];
[self.contentView addSubview:_contactPictureID];
[self.contentView addSubview:_contactName];
[self.contentView addSubview:_emailAddress];
[self.contentView addSubview:_selectedEmailState];
}
return self;
}
Now I am able to instantiate my custom cell. In cellForRowAtIndexPath method
static NSString *CellIdentifier = @"SelectionCell";
SelectionCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[SelectionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; }
And now everything is working as it should be.