Fixing sizing on interaction and activity labels.

This commit is contained in:
Samuel Clay 2013-10-09 16:23:58 -07:00
parent 49c0b4cddb
commit 0f23391cbf
6 changed files with 51 additions and 46 deletions

View file

@ -52,21 +52,21 @@
[super layoutSubviews];
// determine outer bounds
CGRect contentRect = self.contentView.bounds;
[self.activityLabel sizeToFit];
CGRect contentRect = self.frame;
CGRect labelFrame = self.activityLabel.frame;
// position label to bounds
CGRect labelRect = contentRect;
labelRect.origin.x = labelRect.origin.x + leftMargin + avatarSize + leftMargin;
labelRect.origin.y = labelRect.origin.y + topMargin - 1;
labelRect.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin;
labelRect.size.height = contentRect.size.height - topMargin - bottomMargin;
self.activityLabel.frame = labelRect;
[self.activityLabel sizeToFit];
labelFrame.origin.x = leftMargin*2 + avatarSize;
labelFrame.origin.y = topMargin - 1;
labelFrame.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin - 20;
labelFrame.size.height = contentRect.size.height - topMargin - bottomMargin;
self.activityLabel.frame = labelFrame;
}
- (int)setActivity:(NSDictionary *)activity withUserProfile:(NSDictionary *)userProfile withWidth:(int)width {
// must set the height again for dynamic height in heightForRowAtIndexPath in
CGRect activityLabelRect = self.activityLabel.bounds;
CGRect activityLabelRect = self.activityLabel.frame;
activityLabelRect.size.width = width - leftMargin - avatarSize - leftMargin - rightMargin;
self.activityLabel.frame = activityLabelRect;

View file

@ -193,9 +193,9 @@
NSMutableDictionary *userProfile = [appDelegate.dictSocialProfile mutableCopy];
[userProfile setValue:@"You" forKey:@"username"];
int height = [activityCell setActivity:[appDelegate.userActivitiesArray
objectAtIndex:(indexPath.row)]
NSDictionary *activity = [appDelegate.userActivitiesArray
objectAtIndex:(indexPath.row)];
int height = [activityCell setActivity:activity
withUserProfile:userProfile
withWidth:self.frame.size.width - 20];
return height;
@ -220,13 +220,17 @@
// add in loading cell
return [self makeLoadingCell];
} else {
NSMutableDictionary *userProfile = [appDelegate.dictSocialProfile mutableCopy];
[userProfile setValue:@"You" forKey:@"username"];
NSDictionary *activitiy = [appDelegate.userActivitiesArray
NSDictionary *activity = [appDelegate.userActivitiesArray
objectAtIndex:(indexPath.row)];
NSString *category = [activitiy objectForKey:@"category"];
[cell setActivity:activity
withUserProfile:userProfile
withWidth:self.frame.size.width - 20];
NSString *category = [activity objectForKey:@"category"];
if ([category isEqualToString:@"follow"]) {
cell.accessoryType = UITableViewCellAccessoryNone;
} else if ([category isEqualToString:@"signup"]){
@ -239,12 +243,8 @@
UIView *myBackView = [[UIView alloc] initWithFrame:self.frame];
myBackView.backgroundColor = UIColorFromRGB(NEWSBLUR_HIGHLIGHT_COLOR);
cell.selectedBackgroundView = myBackView;
// update the cell information
[cell setActivity: activitiy
withUserProfile:userProfile
withWidth:self.frame.size.width - 20];
}
return cell;
}

View file

@ -56,16 +56,19 @@
[super layoutSubviews];
// determine outer bounds
CGRect contentRect = self.contentView.bounds;
// position label to bounds
CGRect labelRect = contentRect;
labelRect.origin.x = labelRect.origin.x + leftMargin + avatarSize + leftMargin;
labelRect.origin.y = labelRect.origin.y + topMargin - 1;
labelRect.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin;
labelRect.size.height = contentRect.size.height - topMargin - bottomMargin;
self.interactionLabel.frame = labelRect;
[self.interactionLabel sizeToFit];
CGRect contentRect = self.frame;
CGRect labelFrame = self.interactionLabel.frame;
// position avatar to bounds
self.avatarView.frame = CGRectMake(leftMargin, topMargin, avatarSize, avatarSize);
// position label to bounds
labelFrame.origin.x = leftMargin*2 + avatarSize;
labelFrame.origin.y = topMargin - 1;
labelFrame.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin - 20;
labelFrame.size.height = contentRect.size.height - topMargin - bottomMargin;
self.interactionLabel.frame = labelFrame;
}

View file

@ -43,25 +43,26 @@
[super layoutSubviews];
// determine outer bounds
CGRect contentRect = self.contentView.bounds;
[self.activityLabel sizeToFit];
CGRect contentRect = self.frame;
CGRect labelFrame = self.activityLabel.frame;
// position avatar to bounds
self.faviconView.frame = CGRectMake(leftMargin, topMargin, avatarSize, avatarSize);
// position label to bounds
CGRect labelRect = contentRect;
labelRect.origin.x = labelRect.origin.x + leftMargin + avatarSize + leftMargin;
labelRect.origin.y = labelRect.origin.y + topMargin - 1;
labelRect.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin;
labelRect.size.height = contentRect.size.height - topMargin - bottomMargin;
self.activityLabel.frame = labelRect;
labelFrame.origin.x = leftMargin*2 + avatarSize;
labelFrame.origin.y = topMargin - 1;
labelFrame.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin - 20;
labelFrame.size.height = contentRect.size.height - topMargin - bottomMargin;
self.activityLabel.frame = labelFrame;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
self.activityLabel.backgroundColor = UIColorFromRGB(0xd7dadf);
} else {
self.activityLabel.backgroundColor = UIColorFromRGB(0xf6f6f6);
}
self.activityLabel.backgroundColor = [UIColor clearColor];
[self.activityLabel sizeToFit];
}
@end

View file

@ -43,25 +43,26 @@
[super layoutSubviews];
// determine outer bounds
CGRect contentRect = self.contentView.bounds;
[self.interactionLabel sizeToFit];
CGRect contentRect = self.frame;
CGRect labelFrame = self.interactionLabel.frame;
// position avatar to bounds
self.avatarView.frame = CGRectMake(leftMargin, topMargin, avatarSize, avatarSize);
// position label to bounds
CGRect labelRect = contentRect;
labelRect.origin.x = labelRect.origin.x + leftMargin + avatarSize + leftMargin;
labelRect.origin.y = labelRect.origin.y + topMargin - 1;
labelRect.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin;
labelRect.size.height = contentRect.size.height - topMargin - bottomMargin;
self.interactionLabel.frame = labelRect;
labelFrame.origin.x = leftMargin*2 + avatarSize;
labelFrame.origin.y = topMargin - 1;
labelFrame.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin - 20;
labelFrame.size.height = contentRect.size.height - topMargin - bottomMargin;
self.interactionLabel.frame = labelFrame;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
self.interactionLabel.backgroundColor = UIColorFromRGB(0xd7dadf);
} else {
self.interactionLabel.backgroundColor = UIColorFromRGB(0xf6f6f6);
}
self.interactionLabel.backgroundColor = [UIColor clearColor];
[self.interactionLabel sizeToFit];
}
@end

View file

@ -5,7 +5,7 @@
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
#define DEBUG 1
//#define DEBUG 1
#ifdef DEBUG
#define BACKGROUND_REFRESH_SECONDS -5