I am pretty new to iOS and Objective-C.
I have been trying to get a programmatically generated UITableView to work correctly. The table uses a custom UITableViewCell that is in it's own xib file, MeetingsTableViewCell.
Here is how the .xib looks:
And the constraints for the date field:
Here is how it looks when run:
The date and Meeting Mode icon/label are 55 points(?) too far to the right in the simulation.
The main view controller has a width of 320 (I don't seem to be able to change that). The .xib has a width of 375 (I don't seem to be able to change that either). 55 points. Coincidence? I am guessing not.
When I used debug view hierarchy, I discovered that the Cell Wrapper View was 375 points. I added the following code (perhaps more than needed, but I was just trying everything to see if I could figure it out):
cell.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
cell.autoresizesSubviews = true;
cell.cellWrapperView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
cell.cellWrapperView.autoresizesSubviews = true;
I also made sure that I had layoutIfNeeded in the MeetingsTableCellView.m file and added code to resize cellWrapperView
-(void)layoutIfNeeded {
[super layoutIfNeeded];
self.cellWrapperView.frame=self.contentView.bounds;
}
That resized the views correctly to 320, but didn't move the date and meeting mode icon/label.
The debug view now looks like this:
The TableCellView and every full-width thing inside it are 320 points wide. The date and meetings mode icon/label are (correctly) 68 points wide according to debug view. The X position is 297. I do not know how to get the date and meetings mode icon/label to be in the correct position.
As a side note, if I turn the phone to landscape, those widths are all 375 instead of 320, but shouldn't they be 568 now?
Thanks!
EDIT: The code that creates the table.
self.meetings=meetings;
self.meetingsTable=[[UITableView alloc] initWithFrame:self.tableWrapperView.bounds];
self.meetingsTable.delegate = self;
self.meetingsTable.dataSource = self;
self.meetingsTable.autoresizesSubviews = true;
self.meetingsTable.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableWrapperView.autoresizesSubviews = true;
UINib *cellNib=[UINib nibWithNibName:@"MeetingCellView" bundle:nil];
[self.meetingsTable registerNib:cellNib forCellReuseIdentifier:@"MeetingsCell"];
[self.meetingsTable reloadData];
[self.tableWrapperView addSubview:self.meetingsTable];






