Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix table view height issue, need more tests

  • Loading branch information...
commit 01e7404aa58d5ad0588dbdc4f31975357270d716 1 parent 0c987d6
@winfield authored
View
18 Ruby China.xcodeproj/project.pbxproj
@@ -31,6 +31,8 @@
F36A861B1508B3E400A8DE8B /* arrow.png in Resources */ = {isa = PBXBuildFile; fileRef = F36A861A1508B3E400A8DE8B /* arrow.png */; };
F391F0D7151C7FA900A210AC /* RCITopicDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F391F0D6151C7FA900A210AC /* RCITopicDetailViewController.m */; };
F3D5460B1503A5BC00F5A9E3 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3D5460A1503A5BC00F5A9E3 /* QuartzCore.framework */; };
+ F3E6CE6A1578C8A0000F7FF2 /* SVProgressHUD.bundle in Resources */ = {isa = PBXBuildFile; fileRef = F3E6CE671578C8A0000F7FF2 /* SVProgressHUD.bundle */; };
+ F3E6CE6B1578C8A0000F7FF2 /* SVProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = F3E6CE691578C8A0000F7FF2 /* SVProgressHUD.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -82,6 +84,9 @@
F3D546071503A5B000F5A9E3 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
F3D5460A1503A5BC00F5A9E3 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
F3D5460C1503A5CE00F5A9E3 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; };
+ F3E6CE671578C8A0000F7FF2 /* SVProgressHUD.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = SVProgressHUD.bundle; sourceTree = "<group>"; };
+ F3E6CE681578C8A0000F7FF2 /* SVProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVProgressHUD.h; sourceTree = "<group>"; };
+ F3E6CE691578C8A0000F7FF2 /* SVProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVProgressHUD.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -102,6 +107,7 @@
F3269D7F150390E000C7D2DA = {
isa = PBXGroup;
children = (
+ F3E6CE661578C8A0000F7FF2 /* SVProgressHUD */,
F369F256150B42E700A2DE13 /* PullToRefresh */,
F3361F6E1509FC0100B69BC4 /* AFNetworking */,
F3269D94150390E000C7D2DA /* Ruby China */,
@@ -202,6 +208,16 @@
path = "Ruby China";
sourceTree = "<group>";
};
+ F3E6CE661578C8A0000F7FF2 /* SVProgressHUD */ = {
+ isa = PBXGroup;
+ children = (
+ F3E6CE671578C8A0000F7FF2 /* SVProgressHUD.bundle */,
+ F3E6CE681578C8A0000F7FF2 /* SVProgressHUD.h */,
+ F3E6CE691578C8A0000F7FF2 /* SVProgressHUD.m */,
+ );
+ path = SVProgressHUD;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -259,6 +275,7 @@
F3269DA5150390E100C7D2DA /* MainStoryboard_iPad.storyboard in Resources */,
F36A861B1508B3E400A8DE8B /* arrow.png in Resources */,
F369F25E150B49E100A2DE13 /* userPlaceHolder.png in Resources */,
+ F3E6CE6A1578C8A0000F7FF2 /* SVProgressHUD.bundle in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -284,6 +301,7 @@
F3361F8D1509FC0100B69BC4 /* UIImageView+AFNetworking.m in Sources */,
F369F25C150B442500A2DE13 /* PullRefreshTableViewController.m in Sources */,
F391F0D7151C7FA900A210AC /* RCITopicDetailViewController.m in Sources */,
+ F3E6CE6B1578C8A0000F7FF2 /* SVProgressHUD.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
32 Ruby China/RCITopicDetailViewController.m
@@ -67,6 +67,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
if (indexPath.row == 0) {
static NSString *topicDetailCellIdentifier = @"Topic Detail";
UITableViewCell *topicDetailCell = [tableView dequeueReusableCellWithIdentifier:topicDetailCellIdentifier];
+ topicDetailCell.backgroundColor=[UIColor lightGrayColor];
UILabel *titleLabel = (UILabel *)[topicDetailCell viewWithTag:101];
titleLabel.text = [self.topicDetail objectForKey:@"title"];
UILabel *userLabel = (UILabel *)[topicDetailCell viewWithTag:102];
@@ -78,12 +79,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
UILabel *bodyLabel = (UILabel *)[topicDetailCell viewWithTag:105];
NSString *bodyString = [self.topicDetail objectForKey:@"body"];
- CGSize expectedLabelSize = [self topicBodyLabelSize:@"Topic Detail" withBodyString:bodyString];
+ CGSize expectedLabelSize = [self labelSize:@"Topic Detail" withLabelTag:105 withBodyString:bodyString];
+ NSLog(@"Body label size: %f", expectedLabelSize.height);
//adjust the label the the new height.
CGRect newFrame = bodyLabel.frame;
- newFrame.size.height = expectedLabelSize.height + 25.0f;
+ newFrame.size.height = expectedLabelSize.height + 90.0f;
bodyLabel.frame = newFrame;
bodyLabel.text = bodyString;
+ NSLog(@"%@", bodyString);
UIImageView *imageView = (UIImageView *)[topicDetailCell viewWithTag:106];
NSURL *gravatarUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://gravatar.com/avatar/%@.png?s=40", [[self.topicDetail objectForKey:@"user"] objectForKey:@"gravatar_hash"]]];
@@ -93,6 +96,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
} else {
static NSString *topicReplyCellIdentifier = @"Reply";
UITableViewCell *topicReplyCell = [tableView dequeueReusableCellWithIdentifier:topicReplyCellIdentifier];
+ topicReplyCell.backgroundColor=[UIColor lightGrayColor];
NSDictionary *topicReply = [self.topicReplies objectAtIndex:(indexPath.row-1)];
UILabel *titleLabel = (UILabel *)[topicReplyCell viewWithTag:101];
@@ -106,10 +110,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
UILabel *bodyLabel = (UILabel *)[topicReplyCell viewWithTag:105];
NSString *bodyString = [topicReply objectForKey:@"body"];
- CGSize expectedLabelSize = [self topicBodyLabelSize:@"Reply" withBodyString:bodyString];
+ CGSize expectedLabelSize = [self labelSize:@"Reply" withLabelTag:105 withBodyString:bodyString];
//adjust the label the the new height.
CGRect newFrame = bodyLabel.frame;
- newFrame.size.height = expectedLabelSize.height + 25.0f;
+ newFrame.size.height = expectedLabelSize.height + 30.0f;
bodyLabel.frame = newFrame;
bodyLabel.text = bodyString;
@@ -123,24 +127,28 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
NSString *bodyString = [self.topicDetail objectForKey:@"body"];
- CGSize expectedLabelSize = [self topicBodyLabelSize:@"Topic Detail" withBodyString:bodyString];
- return expectedLabelSize.height + 85.0f;
+ NSString *titleString = [self.topicDetail objectForKey:@"title"];
+ CGSize titleLabelSize = [self labelSize:@"Topic Detail" withLabelTag:101 withBodyString:titleString];
+ CGSize bodyLabelSize = [self labelSize:@"Topic Detail" withLabelTag:105 withBodyString:bodyString];
+ NSLog(@"Header size: %f", titleLabelSize.height + bodyLabelSize.height);
+ return titleLabelSize.height + bodyLabelSize.height + 160.0f;
} else {
NSString *bodyString = [[self.topicReplies objectAtIndex:(indexPath.row-1)] objectForKey:@"body"];
- CGSize expectedLabelSize = [self topicBodyLabelSize:@"Reply" withBodyString:bodyString];
- return expectedLabelSize.height + 85.0f;
+ CGSize bodyLabelSize = [self labelSize:@"Reply" withLabelTag:105 withBodyString:bodyString];
+ return bodyLabelSize.height + 85.0f;
}
}
-- (CGSize)topicBodyLabelSize:(NSString *)cellIdentifier withBodyString:(NSString *)bodyString
+- (CGSize)labelSize:(NSString *)cellIdentifier withLabelTag:(NSInteger)tag withBodyString:(NSString *)bodyString
{
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
- UILabel *bodyLabel = (UILabel *)[cell viewWithTag:105];
+ UILabel *label = (UILabel *)[cell viewWithTag:tag];
//Calculate the expected size based on the font and linebreak mode of body label
- CGSize maximumLabelSize = CGSizeMake(296,9999);
+ //CGSize maximumLabelSize = CGSizeMake(296,9999);
+ CGSize maximumLabelSize = CGSizeMake(280,9000);
- CGSize expectedLabelSize = [bodyString sizeWithFont:bodyLabel.font constrainedToSize:maximumLabelSize lineBreakMode:bodyLabel.lineBreakMode];
+ CGSize expectedLabelSize = [bodyString sizeWithFont:label.font constrainedToSize:maximumLabelSize lineBreakMode:label.lineBreakMode];
return expectedLabelSize;
}
View
16 Ruby China/en.lproj/MainStoryboard_iPhone.storyboard
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.1" toolsVersion="2182" systemVersion="11D50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="M3P-kl-mEF">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.1" toolsVersion="2182" systemVersion="11E53" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="M3P-kl-mEF">
<dependencies>
<deployment defaultVersion="1296" identifier="iOS"/>
<development defaultVersion="4200" identifier="xcode"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1179"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1181"/>
</dependencies>
<scenes>
<!--Topics View Controller - Topics-->
@@ -48,14 +48,6 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</label>
- <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="104" contentMode="left" text="19" textAlignment="center" lineBreakMode="clip" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="10" id="fes-O6-JJh">
- <rect key="frame" x="258" y="4" width="22" height="12"/>
- <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
- <color key="backgroundColor" red="0.32537895840423436" green="0.37667854391981725" blue="1" alpha="1" colorSpace="calibratedRGB"/>
- <fontDescription key="fontDescription" type="system" pointSize="11"/>
- <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
- <color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
- </label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
@@ -139,7 +131,7 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</label>
- <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="105" contentMode="left" lineBreakMode="characterWrap" numberOfLines="0" minimumFontSize="10" id="fgZ-h4-uJg">
+ <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="105" contentMode="left" lineBreakMode="wordWrap" numberOfLines="0" minimumFontSize="10" id="fgZ-h4-uJg">
<rect key="frame" x="68" y="70" width="232" height="130"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<string key="text">The War of the Five Kings in Westeros seems to be winding down. In the North, King Stannis Baratheon has installed himself at the Wall and attempts to win the support of the northmen. This is complicated by the fact that the Lannisters have installed Roose Bolton of House Bolton (loyal to the Iron Throne) as Warden of the North, and much of the west coast is under occupation by the Ironborn. On the advice of Jon Snow, Stannis seeks and receives the support of the hill clans and captures Deepwood Motte from Asha Greyjoy. He then chooses to march south to confront the Boltons at Winterfell, but his army becomes snowbound.
@@ -173,7 +165,7 @@ On the Wall itself, Jon Snow has been elected the 998th Lord Commander of the Ni
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="105" contentMode="left" lineBreakMode="characterWrap" numberOfLines="0" minimumFontSize="10" id="rpJ-hs-0KX">
<rect key="frame" x="68" y="42" width="232" height="90"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
- <mutableString key="text">She is left-handed, quick and dexterous. She is a warg, entering her direwolf Nymeria in her dreams and cats in Braavos. She has learned basic swordplay in the Braavosi Water Dancer tradition and knows how to use knives. She received a noble's education, and is said to be good with mathematics and an excellent horse rider. She has proved to know at least a bit of High Valyrian. She also speaks Braavosi with a strong accent and has put some effort into learning the language, under orders from the Kindly Man. She has a quick and curious mind and a pragmatic outlook.</mutableString>
+ <string key="text">She is left-handed, quick and dexterous. She is a warg, entering her direwolf Nymeria in her dreams and cats in Braavos. She has learned basic swordplay in the Braavosi Water Dancer tradition and knows how to use knives. She received a noble's education, and is said to be good with mathematics and an excellent horse rider. She has proved to know at least a bit of High Valyrian. She also speaks Braavosi with a strong accent and has put some effort into learning the language, under orders from the Kindly Man. She has a quick and curious mind and a pragmatic outlook.</string>
<fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
Please sign in to comment.
Something went wrong with that request. Please try again.