Skip to content

Commit

Permalink
Use entire width of dashboard on iPad to display text
Browse files Browse the repository at this point in the history
  • Loading branch information
gonfunko committed Apr 28, 2012
1 parent 0d634b6 commit 48d27f8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
Binary file not shown.
Expand Up @@ -52,11 +52,6 @@
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<AdditionalOptions> <AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions> </AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
Expand Down
19 changes: 16 additions & 3 deletions src/View Controllers/DashboardViewController.m
Expand Up @@ -188,7 +188,13 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
if (indexPath.row == 0) { if (indexPath.row == 0) {
GMDashboardItem *item = [[[[GMDataSource sharedDataSource] currentCourse] dashboardItems] objectAtIndex:indexPath.section]; GMDashboardItem *item = [[[[GMDataSource sharedDataSource] currentCourse] dashboardItems] objectAtIndex:indexPath.section];
//Based on http://stackoverflow.com/questions/2669063/how-to-get-the-size-of-a-nsstring //Based on http://stackoverflow.com/questions/2669063/how-to-get-the-size-of-a-nsstring
CGSize maximumSize = CGSizeMake(300, 9999); CGSize maximumSize;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
maximumSize = CGSizeMake(300, 9999);
} else {
maximumSize = CGSizeMake(self.tableView.bounds.size.width - 20, 9999);
}

CGSize stringSize = [item.contents sizeWithFont:[UIFont fontWithName:@"Helvetica" size:16.0] CGSize stringSize = [item.contents sizeWithFont:[UIFont fontWithName:@"Helvetica" size:16.0]
constrainedToSize:maximumSize constrainedToSize:maximumSize
lineBreakMode:UILineBreakModeWordWrap]; lineBreakMode:UILineBreakModeWordWrap];
Expand Down Expand Up @@ -217,11 +223,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N


if (indexPath.row == 0) { if (indexPath.row == 0) {
((GMTextViewTableCell *)cell).textView.text = item.contents; ((GMTextViewTableCell *)cell).textView.text = item.contents;
CGSize maximumSize = CGSizeMake(300, 9999); CGRect textViewFrame = ((GMTextViewTableCell *)cell).textView.frame;
CGSize maximumSize;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
maximumSize = CGSizeMake(300, 9999);
} else {
maximumSize = CGSizeMake(self.tableView.bounds.size.width - 20, 9999);
}

CGSize stringSize = [item.contents sizeWithFont:[UIFont fontWithName:@"Helvetica" size:16.0] CGSize stringSize = [item.contents sizeWithFont:[UIFont fontWithName:@"Helvetica" size:16.0]
constrainedToSize:maximumSize constrainedToSize:maximumSize
lineBreakMode:UILineBreakModeWordWrap]; lineBreakMode:UILineBreakModeWordWrap];
CGRect textViewFrame = ((GMTextViewTableCell *)cell).textView.frame;
((GMTextViewTableCell *)cell).textView.frame = CGRectMake(textViewFrame.origin.x, textViewFrame.origin.y, textViewFrame.size.width, stringSize.height + 10); ((GMTextViewTableCell *)cell).textView.frame = CGRectMake(textViewFrame.origin.x, textViewFrame.origin.y, textViewFrame.size.width, stringSize.height + 10);
} else { } else {
cell.textLabel.text = [[[item links] objectAtIndex:indexPath.row - 1] objectForKey:@"title"]; cell.textLabel.text = [[[item links] objectAtIndex:indexPath.row - 1] objectForKey:@"title"];
Expand Down
9 changes: 9 additions & 0 deletions src/Views/Table View Cells/GMTextViewTableCell.m
Expand Up @@ -26,6 +26,15 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
return self; return self;
} }


- (void)setFrame:(CGRect)frame {
[super setFrame:frame];
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
self.textView.frame = CGRectMake(frame.origin.x, 0, frame.size.width, frame.size.height);
} else {
self.textView.frame = CGRectMake(frame.origin.x, 0, frame.size.width, frame.size.height);
}
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated - (void)setSelected:(BOOL)selected animated:(BOOL)animated
{ {
[super setSelected:selected animated:animated]; [super setSelected:selected animated:animated];
Expand Down

0 comments on commit 48d27f8

Please sign in to comment.