Skip to content

Commit

Permalink
Just a few layout changes
Browse files Browse the repository at this point in the history
  • Loading branch information
casing committed Feb 25, 2015
1 parent aecad97 commit 7d4b733
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion unnamed/AnswerCollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (void)layoutSubviews {
[super layoutSubviews];

self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width,
self.answerHeight * (self.answerViews.count + 1));// +1 to account additional height
self.answerHeight * self.answerViews.count);// +1 to account additional height

for (int i=0;i<self.answerViews.count;i++) {
AnswerView *view = self.answerViews[i];
Expand Down
17 changes: 8 additions & 9 deletions unnamed/AnswerView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="100.0%" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="R6c-5O-Ip8">
<rect key="frame" x="51" y="5" width="44" height="15"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="100.0%" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="R6c-5O-Ip8">
<rect key="frame" x="51" y="4" width="44" height="15"/>
<constraints>
<constraint firstAttribute="width" constant="28" id="3rh-hP-pRR"/>
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="44" id="NeE-Gv-5Wt"/>
Expand All @@ -32,27 +32,26 @@
</mask>
</variation>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="1. The Answer Is" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6zp-Vs-ovw">
<rect key="frame" x="97" y="5" width="215" height="15"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="1. The Answer Is" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6zp-Vs-ovw">
<rect key="frame" x="97" y="4" width="215" height="15"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="O7j-Bf-ACJ" customClass="GRKBarGraphView">
<rect key="frame" x="8" y="8" width="40" height="8"/>
<rect key="frame" x="8" y="7" width="40" height="8"/>
<constraints>
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="40" id="0l3-oJ-CVJ"/>
<constraint firstAttribute="height" constant="8" id="eTG-9f-CWP"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="R6c-5O-Ip8" firstAttribute="centerY" secondItem="6zp-Vs-ovw" secondAttribute="centerY" id="AzX-HI-mZd"/>
<constraint firstAttribute="centerY" secondItem="6zp-Vs-ovw" secondAttribute="centerY" id="6pL-yH-yRa"/>
<constraint firstAttribute="centerY" secondItem="O7j-Bf-ACJ" secondAttribute="centerY" id="LpG-ze-sL5"/>
<constraint firstItem="6zp-Vs-ovw" firstAttribute="leading" relation="lessThanOrEqual" secondItem="R6c-5O-Ip8" secondAttribute="trailing" constant="3" id="NXq-7s-fxT"/>
<constraint firstAttribute="centerY" secondItem="R6c-5O-Ip8" secondAttribute="centerY" id="PPs-bc-FhN"/>
<constraint firstAttribute="trailing" secondItem="6zp-Vs-ovw" secondAttribute="trailing" constant="8" id="aqr-RD-inv"/>
<constraint firstItem="O7j-Bf-ACJ" firstAttribute="centerY" secondItem="6zp-Vs-ovw" secondAttribute="centerY" id="b9l-Fr-vO8"/>
<constraint firstItem="O7j-Bf-ACJ" firstAttribute="top" secondItem="m8k-6m-S8c" secondAttribute="top" constant="8" id="dpT-8x-DnB"/>
<constraint firstItem="O7j-Bf-ACJ" firstAttribute="centerY" secondItem="R6c-5O-Ip8" secondAttribute="centerY" id="f0l-31-lgq"/>
<constraint firstItem="O7j-Bf-ACJ" firstAttribute="leading" secondItem="m8k-6m-S8c" secondAttribute="leading" constant="8" id="ikq-q4-iQg"/>
<constraint firstItem="R6c-5O-Ip8" firstAttribute="leading" secondItem="O7j-Bf-ACJ" secondAttribute="trailing" constant="3" id="onP-rZ-joU"/>
</constraints>
Expand Down
50 changes: 26 additions & 24 deletions unnamed/HomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,30 @@ @interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, Su
@implementation HomeViewController

- (void) setupTestData {
// for (int i=0; i<20; i++) {
// Survey *survey = [[Survey alloc] init];
// survey.question = [[Question alloc] init];
// survey.question.text = [NSString stringWithFormat:@"Question %d?", i];
// survey.question.anonymous = (i%2==0)?YES:NO;
// survey.question.complete = (i%2==0)?NO:YES;
//
// survey.user = [[User alloc] init];
// survey.user.name = [NSString stringWithFormat:@"Name %d", i];
//
// NSMutableArray *answers = [[NSMutableArray alloc] init];
// for (int j=0; j < ((i % 4) + 2); j++) {
// Answer *answer = [[Answer alloc] init];
// answer.count = i * j;
// answer.text = [NSString stringWithFormat:@"Answer %d - %d", i, j];
// [answers addObject:answer];
// }
// survey.answers = [NSArray arrayWithArray:answers];
// survey.voted = (i%2 == 0)?YES:NO;
//
// [self.surveys addObject:survey];
// }
for (int i=0; i<20; i++) {
Survey *survey = [[Survey alloc] init];
survey.question = [[Question alloc] init];
survey.question.text = [NSString stringWithFormat:@"Question %d?", i];
survey.question.anonymous = (i%2==0)?YES:NO;
survey.question.complete = (i%2==0)?NO:YES;

survey.user = [[User alloc] init];
survey.user.name = [NSString stringWithFormat:@"Name %d", i];

NSInteger total = 0;
NSMutableArray *answers = [[NSMutableArray alloc] init];
for (int j=0; j < ((i % 4) + 2); j++) {
Answer *answer = [[Answer alloc] init];
answer.count = i * j;
total += answer.count;
answer.text = [NSString stringWithFormat:@"Answer %d - %d", i, j];
[answers addObject:answer];
}
survey.answers = [NSArray arrayWithArray:answers];
survey.voted = (i%2 == 0)?YES:NO;
survey.totalVotes = total;
[self.surveys addObject:survey];
}
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
Expand Down Expand Up @@ -187,7 +189,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
[self.prototypeSurveyCell layoutIfNeeded];
CGSize size = [self.prototypeSurveyCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
// NSLog(@"Row %ld has height %f", indexPath.row, size.height);
return size.height;
return size.height + 1;
}

#pragma mark - SurveyViewCellDelegate methods
Expand Down Expand Up @@ -225,4 +227,4 @@ - (void)configureCell:(UITableViewCell *)pCell forRowAtIndexPath:(NSIndexPath *)
}
}

@end
@end

0 comments on commit 7d4b733

Please sign in to comment.