Created
May 16, 2011 00:33
-
-
Save aaronbrethorst/973722 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Classes/MenuViewController.m b/Classes/MenuViewController.m | |
index 9c36a45..16bc15b 100755 | |
--- a/Classes/MenuViewController.m | |
+++ b/Classes/MenuViewController.m | |
@@ -11,6 +11,7 @@ | |
#import "StackScrollViewAppDelegate.h" | |
#import "RootViewController.h" | |
#import "StackScrollViewController.h" | |
+#import "MenuTableViewCell.h" | |
#define kCellText @"CellText" | |
#define kCellImage @"CellImage" | |
@@ -34,11 +35,11 @@ | |
[_cellContents addObject:[NSDictionary dictionaryWithObjectsAndKeys:[UIImage imageNamed:@"06-magnify.png"], kCellImage, NSLocalizedString(@"Search",@""), kCellText, nil]]; | |
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain]; | |
- [_tableView setDelegate:self]; | |
- [_tableView setDataSource:self]; | |
- [_tableView setBackgroundColor:[UIColor clearColor]]; | |
- _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 1)]; | |
- [self.view addSubview:_tableView]; | |
+ _tableView.delegate = self; | |
+ _tableView.dataSource = self; | |
+ _tableView.backgroundColor = [UIColor clearColor]; | |
+ _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; | |
+ [self.view addSubview:_tableView]; | |
} | |
return self; | |
} | |
@@ -87,16 +88,15 @@ | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
static NSString *CellIdentifier = @"Cell"; | |
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; | |
+ MenuTableViewCell *cell = (MenuTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; | |
if (cell == nil) { | |
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; | |
- UIView* bgView = [[[UIView alloc] init] autorelease]; | |
- [bgView setBackgroundColor:[UIColor colorWithWhite:2 alpha:0.2]]; | |
- [cell setSelectedBackgroundView:bgView]; | |
+ cell = [[[MenuTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; | |
} | |
cell.textLabel.text = [[_cellContents objectAtIndex:indexPath.row] objectForKey:kCellText]; | |
cell.imageView.image = [[_cellContents objectAtIndex:indexPath.row] objectForKey:kCellImage]; | |
+ | |
+ cell.glowView.hidden = indexPath.row != 3; | |
return cell; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (id)initWithFrame:(CGRect)aRect | |
{ | |
if ((self = [super initWithFrame:aRect])) | |
{ | |
UIView* topLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 1)]; | |
topLine.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.25]; | |
[self addSubview:topLine]; | |
[topLine release]; | |
UIImageView *watermark = [[UIImageView alloc] initWithFrame:CGRectMake(0, 1, 200, 79)]; | |
watermark.contentMode = UIViewContentModeCenter; | |
watermark.image = [UIImage imageNamed:@"watermark.png"]; | |
[self addSubview:watermark]; | |
[watermark release]; | |
} | |
return self; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Classes/MenuViewController.m b/Classes/MenuViewController.m | |
index 1ac2a71..84a2e89 100755 | |
--- a/Classes/MenuViewController.m | |
+++ b/Classes/MenuViewController.m | |
@@ -13,6 +13,7 @@ | |
#import "StackScrollViewController.h" | |
#import "MenuTableViewCell.h" | |
#import "MenuHeaderView.h" | |
+#import "MenuWatermarkFooter.h" | |
#define kCellText @"CellText" | |
#define kCellImage @"CellImage" | |
@@ -44,6 +45,7 @@ | |
_tableView.dataSource = self; | |
_tableView.backgroundColor = [UIColor clearColor]; | |
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone; | |
+ _tableView.tableFooterView = [[[MenuWatermarkFooter alloc] initWithFrame:CGRectMake(0, 0, 200, 80)] | |
[self.view addSubview:_tableView]; | |
} | |
return self; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (int)heightForTweetWithText:(NSString*)tweetText | |
{ | |
CGFloat height = 0; | |
height += 12; // top padding. | |
height += 18; // author label. | |
height += 5; // padding between author and tweet. | |
CGSize tweetTextSize = [tweetText sizeWithFont:[UIFont boldSystemFontOfSize:[UIFont labelFontSize]] constrainedToSize:CGSizeMake(390, 10000) lineBreakMode:UILineBreakModeWordWrap]; | |
height += tweetTextSize.height; | |
height += 12; // bottom padding. | |
return (int)height; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Classes/DataViewController.h b/Classes/DataViewController.h | |
index 0cce20f..756889c 100755 | |
--- a/Classes/DataViewController.h | |
+++ b/Classes/DataViewController.h | |
@@ -14,6 +14,7 @@ | |
RoundedUITableView* _tableView; | |
NSArray *tweets; | |
+ NSDateFormatter *formatter; | |
} | |
- (id)initWithFrame:(CGRect)frame squareCorners:(BOOL)squareCorners; | |
diff --git a/Classes/DataViewController.m b/Classes/DataViewController.m | |
index c60be8f..cb71089 100755 | |
--- a/Classes/DataViewController.m | |
+++ b/Classes/DataViewController.m | |
@@ -12,6 +12,7 @@ | |
#import "StackScrollViewController.h" | |
#import "RoundedUITableView.h" | |
#import "TweetTableViewCell.h" | |
+#import "NSDate+Formatting.h" | |
@implementation DataViewController | |
@synthesize tableView = _tableView; | |
@@ -25,6 +26,17 @@ | |
{ | |
tweets = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tweets" of | |
+ //http://stackoverflow.com/questions/2002544/iphone-twitter-api-converting-time | |
+ formatter = [[NSDateFormatter alloc] init]; | |
+ NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; | |
+ [formatter setLocale:usLocale]; | |
+ [usLocale release]; | |
+ [formatter setDateStyle:NSDateFormatterLongStyle]; | |
+ [formatter setFormatterBehavior:NSDateFormatterBehavior10_4]; | |
+ | |
+ // see http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns | |
+ [formatter setDateFormat: @"EEE MMM dd HH:mm:ss +0000 yyyy"]; | |
+ | |
[self.view setFrame:frame]; | |
_tableView = [[RoundedUITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, | |
@@ -87,11 +99,14 @@ | |
} | |
NSDictionary *tweet = [tweets objectAtIndex:indexPath.row]; | |
- | |
+ | |
+ NSDate *createdAt = [formatter dateFromString:[tweet objectForKey:@"created_at"]]; | |
+ | |
cell.imageView.image = [UIImage imageNamed:@"avatar.png"]; | |
cell.authorLabel.text = [[tweet objectForKey:@"user"] objectForKey:@"screen_name"]; | |
cell.tweetLabel.text = [tweet objectForKey:@"text"]; | |
- | |
+ cell.timestampLabel.text = [createdAt distanceOfTimeInWords]; | |
+ | |
return cell; | |
} | |
@@ -117,6 +132,7 @@ | |
- (void)dealloc { | |
+ [formatter release]; | |
[tweets release]; | |
[super dealloc]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment