Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added date subtitle to post view. Added code for repositioning labels…

… in event view.
  • Loading branch information...
commit 0b7b9453195d3c0bfcdf9f3900db184a5224b49a 1 parent 2727166
@akinsey akinsey authored
View
26 HI Capacity/EventDetailsViewController.m
@@ -37,14 +37,38 @@ - (void)viewDidLoad
self.navigationItem.titleView = imageView;
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"noise"]];
+ // Remove padding from UITextView
+ eventDescText.contentInset = UIEdgeInsetsMake(-11,-8,0,0);
+
+ // Set and resize title label
[[self eventSummaryLabel] setText:[event summary]];
- [[self eventDescText] setText:[event description]];
+ [eventSummaryLabel setNumberOfLines:0];
+ [eventSummaryLabel sizeToFit]; // Shrink the frame to fit the text
+
+ // Set spacing and get position of where to place next label
+ int labelSpacing = 10;
+ int newY = eventSummaryLabel.frame.size.height + eventSummaryLabel.frame.origin.y + labelSpacing;
// Create the date/time text
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"EEEE, MMMM d yyyy h:mm a z"];
[formatter setTimeZone:[NSTimeZone systemTimeZone]];
[[self eventTimeLabel] setText:[formatter stringFromDate:[event startTime]]];
+
+ // Adjust position of the date label
+ CGRect frame = eventTimeLabel.frame;
+ frame.origin.y = newY;
+ eventTimeLabel.frame = frame;
+ [eventTimeLabel setNumberOfLines:0];
+
+ // Set Description text
+ [[self eventDescText] setText:[event description]];
+
+ // Adjust position of event description textview]
+ newY = eventTimeLabel.frame.size.height + eventTimeLabel.frame.origin.y + labelSpacing;
+ frame = eventDescText.frame;
+ frame.origin.y = newY;
+ eventDescText.frame = frame;
}
- (void)viewDidUnload
View
BIN  HI Capacity/Images/posts@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  HI Capacity/Images/posts_selected@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
91 HI Capacity/PostContentViewController.m
@@ -31,41 +31,38 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- (void)viewDidLoad
{
- [super viewDidLoad];
+ [super viewDidLoad];
- // Load HI Capacity logo
- UIImage *image = [UIImage imageNamed: @"logo"];
- UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
- self.navigationItem.titleView = imageView;
+ // Load HI Capacity logo
+ UIImage *image = [UIImage imageNamed: @"logo"];
+ UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
+ self.navigationItem.titleView = imageView;
+
+ // Set the post title label
+ [titleLabel setText:[post title]];
+ [titleLabel setNumberOfLines:0];
+ [titleLabel sizeToFit]; // Shrink the frame to fit the text
+
+ // Set spacing and get position of where to place next label
+ int labelSpacing = 10;
+ int newY = titleLabel.frame.size.height + titleLabel.frame.origin.y + labelSpacing;
- // Set the post title label
- [titleLabel setText:[post title]];
- [titleLabel setNumberOfLines:0];
- [titleLabel sizeToFit]; // Shrink the frame to fit the text
-
- // Set spacing and get position of where to place next label
- int labelSpacing = 10;
- int newY = titleLabel.frame.size.height + titleLabel.frame.origin.y + labelSpacing;
-
- // Set the date label
- NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
-// [dateFormat setDateFormat:@"EEE, d MMM yyyy HH:mm:ss ZZZ"];
-// [dateFormat setTimeZone:[NSTimeZone systemTimeZone]];
-// NSDate *newDate = [dateFormat dateFromString:[post objectForKey:@"date"]];
- [dateFormat setDateFormat:@"EEEE, MMM d yyyy"];
- [dateLabel setText:[NSString stringWithFormat:@"%@", [dateFormat stringFromDate:[post date]]]];
-
- // Adjust position of the date label
- CGRect frame = dateLabel.frame;
- frame.origin.y = newY;
- dateLabel.frame = frame;
- [dateLabel setNumberOfLines:0];
- [dateLabel sizeToFit];
-
- // Set settings on the UIWebView
- [contentLabel setOpaque:FALSE];
- [contentLabel setBackgroundColor:[UIColor clearColor]];
+ // Set the date label
+ NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
+ [dateFormat setDateFormat:@"EEEE, MMM d yyyy"];
+ [dateLabel setText:[dateFormat stringFromDate:[post date]]];
+ // Adjust position of the date label
+ CGRect frame = dateLabel.frame;
+ frame.origin.y = newY;
+ dateLabel.frame = frame;
+ [dateLabel setNumberOfLines:0];
+ [dateLabel sizeToFit];
+
+ // Set settings on the UIWebView
+ [contentLabel setOpaque:FALSE];
+ [contentLabel setBackgroundColor:[UIColor clearColor]];
+
// Wrap the post content is html tags with CSS font information
NSString* postContent = [post content];
NSString* htmlContentString = [NSString stringWithFormat:
@@ -77,22 +74,22 @@ - (void)viewDidLoad
"<p>%@</p>"
"</body></html>", postContent];
- // Set the content of the UIWebView and set it's y position
- [contentLabel loadHTMLString:htmlContentString baseURL:nil];
- newY = dateLabel.frame.size.height + dateLabel.frame.origin.y + labelSpacing;
- frame = contentLabel.frame;
- frame.origin.y = newY;
- contentLabel.frame = frame;
-
- //Disable bounce scroll on UIWebView
- for(UIView *tmpView in ((UIWebView *)contentLabel).subviews){
- if([tmpView isKindOfClass:[UIScrollView class] ]){
- ((UIScrollView*)tmpView).scrollEnabled = NO;
- ((UIScrollView*)tmpView).bounces = NO;
- break;
- }
- }
+ // Set the content of the UIWebView and set it's y position
+ [contentLabel loadHTMLString:htmlContentString baseURL:nil];
+ newY = dateLabel.frame.size.height + dateLabel.frame.origin.y + labelSpacing;
+ frame = contentLabel.frame;
+ frame.origin.y = newY;
+ contentLabel.frame = frame;
+ //Disable bounce scroll on UIWebView
+ for(UIView *tmpView in ((UIWebView *)contentLabel).subviews){
+ if([tmpView isKindOfClass:[UIScrollView class] ]){
+ ((UIScrollView*)tmpView).scrollEnabled = NO;
+ ((UIScrollView*)tmpView).bounces = NO;
+ break;
+ }
+ }
+
// Hack to use scalePageToFit but also disable the pinch/zoom of the UIWebView
UIScrollView *webViewScrollView = [contentLabel.subviews objectAtIndex:0];
webViewScrollView.delegate = self;//self must be UIScrollViewDelegate
View
3  HI Capacity/PostsViewController.m
@@ -95,6 +95,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
Post *post = [posts objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[post title]];
+ NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
+ [dateFormat setDateFormat:@"MMM d yyyy"];
+ [[cell detailTextLabel] setText:[dateFormat stringFromDate:[post date]]];
return cell;
}
View
65 HI Capacity/en.lproj/MainStoryboard_iPhone.storyboard
@@ -119,12 +119,28 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
- <tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" id="6se-8l-jhq">
+ <tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="AFq-PC-8i0" detailTextLabel="fuM-hj-Fc5" style="IBUITableViewCellStyleSubtitle" id="6se-8l-jhq">
<rect key="frame" x="0.0" y="22" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="300" height="43"/>
<autoresizingMask key="autoresizingMask"/>
+ <subviews>
+ <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="AFq-PC-8i0">
+ <rect key="frame" x="10" y="2" width="38" height="22"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+ </label>
+ <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="fuM-hj-Fc5">
+ <rect key="frame" x="10" y="24" width="47" height="18"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <fontDescription key="fontDescription" type="system" pointSize="14"/>
+ <color key="textColor" red="0.50196078431372548" green="0.50196078431372548" blue="0.50196078431372548" alpha="1" colorSpace="calibratedRGB"/>
+ <color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+ </label>
+ </subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<connections>
@@ -262,14 +278,14 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" minimumFontSize="14" id="zPp-Uh-Nhx">
- <rect key="frame" x="13" y="10" width="295" height="50"/>
+ <rect key="frame" x="20" y="20" width="280" height="58"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" id="xf0-ps-oiW">
- <rect key="frame" x="13" y="84" width="295" height="277"/>
+ <rect key="frame" x="20" y="90" width="280" height="277"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
@@ -277,7 +293,7 @@
<dataDetectorType key="dataDetectorTypes" link="YES" calendarEvent="YES"/>
</textView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="2sd-8b-Ijk">
- <rect key="frame" x="13" y="60" width="295" height="21"/>
+ <rect key="frame" x="20" y="69" width="280" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
@@ -304,47 +320,6 @@
<image name="line.png" width="320" height="2"/>
<image name="pin_map.png" width="24" height="24"/>
</resources>
- <classes>
- <class className="AboutViewController" superclassName="UIViewController">
- <source key="sourceIdentifier" type="project" relativePath="./Classes/AboutViewController.h"/>
- <relationships>
- <relationship kind="action" name="mapButtonClicked:"/>
- <relationship kind="outlet" name="mapView" candidateClass="MKMapView"/>
- </relationships>
- </class>
- <class className="CalendarViewController" superclassName="TKCalendarMonthTableViewController">
- <source key="sourceIdentifier" type="project" relativePath="./Classes/CalendarViewController.h"/>
- </class>
- <class className="EventDetailsViewController" superclassName="UIViewController">
- <source key="sourceIdentifier" type="project" relativePath="./Classes/EventDetailsViewController.h"/>
- <relationships>
- <relationship kind="outlet" name="eventDescText" candidateClass="UITextView"/>
- <relationship kind="outlet" name="eventSummaryLabel" candidateClass="UILabel"/>
- <relationship kind="outlet" name="eventTimeLabel" candidateClass="UILabel"/>
- </relationships>
- </class>
- <class className="PostContentViewController" superclassName="UIViewController">
- <source key="sourceIdentifier" type="project" relativePath="./Classes/PostContentViewController.h"/>
- <relationships>
- <relationship kind="outlet" name="contentLabel" candidateClass="UIWebView"/>
- <relationship kind="outlet" name="dateLabel" candidateClass="UILabel"/>
- <relationship kind="outlet" name="scrollView" candidateClass="UIScrollView"/>
- <relationship kind="outlet" name="titleLabel" candidateClass="UILabel"/>
- </relationships>
- </class>
- <class className="PostsViewController" superclassName="UITableViewController">
- <source key="sourceIdentifier" type="project" relativePath="./Classes/PostsViewController.h"/>
- <relationships>
- <relationship kind="outlet" name="postTableView" candidateClass="UITableView"/>
- </relationships>
- </class>
- <class className="TKCalendarMonthTableViewController" superclassName="TKCalendarMonthViewController">
- <source key="sourceIdentifier" type="project" relativePath="./Classes/TKCalendarMonthTableViewController.h"/>
- </class>
- <class className="TKCalendarMonthViewController" superclassName="UIViewController">
- <source key="sourceIdentifier" type="project" relativePath="./Classes/TKCalendarMonthViewController.h"/>
- </class>
- </classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
Please sign in to comment.
Something went wrong with that request. Please try again.