Skip to content

Commit

Permalink
Merge pull request #709 from DoSomething/issue-708
Browse files Browse the repository at this point in the history
Dynamic NoSignupsCell height
  • Loading branch information
aaronschachter committed Dec 23, 2015
2 parents fa84955 + c0e741f commit a62408f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Lets Do This/Controllers/Profile/LDTProfileViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ - (void)viewDidLoad {
[self.tableView registerNib:[UINib nibWithNibName:@"LDTProfileCampaignTableViewCell" bundle:nil] forCellReuseIdentifier:@"campaignCell"];
[self.tableView registerNib:[UINib nibWithNibName:@"LDTProfileReportbackItemTableViewCell" bundle:nil] forCellReuseIdentifier:@"reportbackItemCell"];
[self.tableView registerNib:[UINib nibWithNibName:@"LDTProfileNoSignupsTableViewCell" bundle:nil] forCellReuseIdentifier:@"noSignupsCell"];

UINib *reportbackItemCellNib = [UINib nibWithNibName:@"LDTProfileReportbackItemTableViewCell" bundle:nil];
self.reportbackItemSizingCell = [[reportbackItemCellNib instantiateWithOwner:nil options:nil] firstObject];

Expand Down Expand Up @@ -367,9 +368,15 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == LDTProfileSectionTypeCampaign) {
if (self.isProfileLoaded && self.user.campaignSignups.count == 0) {
// Render noSignupsCell as full height of remaining tableView.
// @todo: Real math here, this is a guestimate.
return self.tableView.bounds.size.height - 180;
// Create a sizing profileHeader cell to get its height.
UINib *profileHeaderCellNib = [UINib nibWithNibName:@"LDTProfileHeaderTableViewCell" bundle:nil];
LDTProfileHeaderTableViewCell *profileHeaderSizingCell = [[profileHeaderCellNib instantiateWithOwner:nil options:nil] firstObject];
[self configureHeaderCell:profileHeaderSizingCell];
profileHeaderSizingCell.frame = CGRectMake(0, 0, CGRectGetWidth(self.tableView.bounds), CGRectGetHeight(profileHeaderSizingCell.frame));
[profileHeaderSizingCell setNeedsLayout];
[profileHeaderSizingCell layoutIfNeeded];
CGFloat profileHeaderHeight = [profileHeaderSizingCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
return self.tableView.bounds.size.height - profileHeaderHeight;
}
DSOCampaignSignup *signup = self.user.campaignSignups[indexPath.row];
if (signup.reportbackItem) {
Expand Down

0 comments on commit a62408f

Please sign in to comment.