I develop a custom tableviewcell for use across my projcect, named UpdatesTableViewCell class. what I've got up until now has been shown in the snapshots at the bottom of this question.
Only problem I've been unfortunately experiencing is all about that the app layout only work in portrait orientation, but not in landscape mode.
That's to say, when my iphone get rotated to landscape, the above mentioned custom cell doesn't seem to fill up all the space of the containing table view, leaving some gap after it. That would not be of pleasant user experience.
please note that I also set autosizing to tell the tableviewcell to expand both left and right, filling up the container's space. (See 1st snapshot picture)
any advice to get it right in landscape orientation would be very much appreciated
..
UpdatesTableViewCell.xib
UpdatesTableViewCell.h
#import <UIKit/UIKit.h>
@interface UpdatesTableViewCell : UITableViewCell
@end
UpdatesTableViewCell.m
#import "UpdatesTableViewCell.h"
@implementation UpdatesTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
and the final piece here is a snippet of code in ResultViewController.m (The parent UITableViewController where the UpdatesTableViewCell get used)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UpdatesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"UpdatesTableViewCell" owner:nil options:nil];
for (UIView *view in views) {
if([view isKindOfClass:[UITableViewCell class]])
{
cell = (UpdatesTableViewCell*)view;
}
}
}
return cell;
}
Here is the unexpected result as mentioned: