diff --git a/examples/ASDKgram/Sample.xcodeproj/project.pbxproj b/examples/ASDKgram/Sample.xcodeproj/project.pbxproj index a534c90a35..ad4486d752 100644 --- a/examples/ASDKgram/Sample.xcodeproj/project.pbxproj +++ b/examples/ASDKgram/Sample.xcodeproj/project.pbxproj @@ -27,7 +27,7 @@ 7688438E1CAA37EF00D8629E /* PhotoFeedNodeController.m in Sources */ = {isa = PBXBuildFile; fileRef = 768843761CAA37EF00D8629E /* PhotoFeedNodeController.m */; }; 768843901CAA37EF00D8629E /* PhotoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 768843781CAA37EF00D8629E /* PhotoModel.m */; }; 768843911CAA37EF00D8629E /* PhotoTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 768843791CAA37EF00D8629E /* PhotoTableViewCell.m */; }; - 768843921CAA37EF00D8629E /* PhotoTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7688437A1CAA37EF00D8629E /* PhotoTableViewController.m */; }; + 768843921CAA37EF00D8629E /* PhotoFeedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7688437A1CAA37EF00D8629E /* PhotoFeedViewController.m */; }; 768843931CAA37EF00D8629E /* UserModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7688437B1CAA37EF00D8629E /* UserModel.m */; }; 768843951CAA37EF00D8629E /* UserRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7688437D1CAA37EF00D8629E /* UserRowView.m */; }; 768843961CAA37EF00D8629E /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7688437E1CAA37EF00D8629E /* Utilities.m */; }; @@ -55,7 +55,7 @@ 7688435E1CAA37EF00D8629E /* PhotoFeedNodeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoFeedNodeController.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 768843601CAA37EF00D8629E /* PhotoModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 768843611CAA37EF00D8629E /* PhotoTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoTableViewCell.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; - 768843621CAA37EF00D8629E /* PhotoTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoTableViewController.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843621CAA37EF00D8629E /* PhotoFeedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoFeedViewController.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 768843631CAA37EF00D8629E /* UserModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = UserModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 768843651CAA37EF00D8629E /* UserRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = UserRowView.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 768843661CAA37EF00D8629E /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Utilities.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; @@ -74,7 +74,7 @@ 768843761CAA37EF00D8629E /* PhotoFeedNodeController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoFeedNodeController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 768843781CAA37EF00D8629E /* PhotoModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 768843791CAA37EF00D8629E /* PhotoTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoTableViewCell.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - 7688437A1CAA37EF00D8629E /* PhotoTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoTableViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 7688437A1CAA37EF00D8629E /* PhotoFeedViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoFeedViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 7688437B1CAA37EF00D8629E /* UserModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = UserModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 7688437D1CAA37EF00D8629E /* UserRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = UserRowView.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 7688437E1CAA37EF00D8629E /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = Utilities.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; @@ -181,8 +181,8 @@ 767A5F161CAA3D96004CDA8D /* UIKit */ = { isa = PBXGroup; children = ( - 768843621CAA37EF00D8629E /* PhotoTableViewController.h */, - 7688437A1CAA37EF00D8629E /* PhotoTableViewController.m */, + 768843621CAA37EF00D8629E /* PhotoFeedViewController.h */, + 7688437A1CAA37EF00D8629E /* PhotoFeedViewController.m */, ); name = UIKit; sourceTree = ""; @@ -371,7 +371,7 @@ files = ( 768843891CAA37EF00D8629E /* main.m in Sources */, 7688438C1CAA37EF00D8629E /* PhotoCollectionViewCell.m in Sources */, - 768843921CAA37EF00D8629E /* PhotoTableViewController.m in Sources */, + 768843921CAA37EF00D8629E /* PhotoFeedViewController.m in Sources */, 768843821CAA37EF00D8629E /* CommentModel.m in Sources */, 768843831CAA37EF00D8629E /* CommentsNode.m in Sources */, 768843961CAA37EF00D8629E /* Utilities.m in Sources */, diff --git a/examples/ASDKgram/Sample/AppDelegate.m b/examples/ASDKgram/Sample/AppDelegate.m index 593d1516bc..39ecc14023 100644 --- a/examples/ASDKgram/Sample/AppDelegate.m +++ b/examples/ASDKgram/Sample/AppDelegate.m @@ -7,7 +7,7 @@ // #import "AppDelegate.h" -#import "PhotoTableViewController.h" +#import "PhotoFeedViewController.h" #import "PhotoFeedNodeController.h" #import "Utilities.h" @@ -24,7 +24,7 @@ asdkHomeFeedNavCtrl.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"ASDK" image:[UIImage imageNamed:@"home"] tag:0]; // ASDK Home Feed viewController & navController - PhotoTableViewController *uikitHomeFeedVC = [[PhotoTableViewController alloc] init]; + PhotoFeedViewController *uikitHomeFeedVC = [[PhotoFeedViewController alloc] init]; UINavigationController *uikitHomeFeedNavCtrl = [[UINavigationController alloc] initWithRootViewController:uikitHomeFeedVC]; uikitHomeFeedNavCtrl.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"UIKit" image:[UIImage imageNamed:@"home"] tag:0]; diff --git a/examples/ASDKgram/Sample/PhotoTableViewController.h b/examples/ASDKgram/Sample/PhotoFeedViewController.h similarity index 57% rename from examples/ASDKgram/Sample/PhotoTableViewController.h rename to examples/ASDKgram/Sample/PhotoFeedViewController.h index 54f002daec..5fc25f4656 100644 --- a/examples/ASDKgram/Sample/PhotoTableViewController.h +++ b/examples/ASDKgram/Sample/PhotoFeedViewController.h @@ -1,5 +1,5 @@ // -// PhotoTableViewController.h +// PhotoFeedViewController.h // ASDKgram // // Created by Hannah Troisi on 2/17/16. @@ -8,8 +8,6 @@ #import -@interface PhotoTableViewController : UITableViewController - -- (void)refreshFeed; +@interface PhotoFeedViewController : UIViewController @end diff --git a/examples/ASDKgram/Sample/PhotoTableViewController.m b/examples/ASDKgram/Sample/PhotoFeedViewController.m similarity index 78% rename from examples/ASDKgram/Sample/PhotoTableViewController.m rename to examples/ASDKgram/Sample/PhotoFeedViewController.m index 040f45eb2f..1df83f1120 100644 --- a/examples/ASDKgram/Sample/PhotoTableViewController.m +++ b/examples/ASDKgram/Sample/PhotoFeedViewController.m @@ -1,40 +1,44 @@ // -// PhotoTableViewController.m +// PhotoFeedViewController.m // ASDKgram // // Created by Hannah Troisi on 2/17/16. // Copyright © 2016 Hannah Troisi. All rights reserved. // -#import "PhotoTableViewController.h" +#import "PhotoFeedViewController.h" #import "Utilities.h" #import "PhotoTableViewCell.h" #import "PhotoFeedModel.h" #define AUTO_TAIL_LOADING_NUM_SCREENFULS 2.5 -@implementation PhotoTableViewController +@interface PhotoFeedViewController () +@end + +@implementation PhotoFeedViewController { PhotoFeedModel *_photoFeed; + UITableView *_tableView; UIView *_statusBarOpaqueUnderlayView; } #pragma mark - Lifecycle -- (instancetype)initWithStyle:(UITableViewStyle)style +- (instancetype)init { - self = [super initWithStyle:style]; + self = [super initWithNibName:nil bundle:nil]; if (self) { - self.navigationItem.title = @"UIKit"; [self.navigationController setNavigationBarHidden:YES]; _photoFeed = [[PhotoFeedModel alloc] initWithPhotoFeedModelType:PhotoFeedModelTypePopular imageSize:[self imageSizeForScreenWidth]]; [self refreshFeed]; - self.refreshControl = [[UIRefreshControl alloc] init]; - [self.refreshControl addTarget:self action:@selector(refreshFeed) forControlEvents:UIControlEventValueChanged]; + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; + _tableView.delegate = self; + _tableView.dataSource = self; // hack to make status bar opaque _statusBarOpaqueUnderlayView = [[UIView alloc] init]; @@ -50,9 +54,11 @@ { [super viewDidLoad]; - self.tableView.allowsSelection = NO; - self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - [self.tableView registerClass:[PhotoTableViewCell class] forCellReuseIdentifier:@"photoCell"]; + [self.view addSubview:_tableView]; + _tableView.frame = self.view.bounds; + _tableView.allowsSelection = NO; + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + [_tableView registerClass:[PhotoTableViewCell class] forCellReuseIdentifier:@"photoCell"]; } @@ -78,7 +84,6 @@ { // small first batch [_photoFeed refreshFeedWithCompletionBlock:^(NSArray *newPhotos){ - [self insertNewRowsInTableView:newPhotos]; [self requestCommentsForPhotos:newPhotos]; @@ -102,12 +107,12 @@ [photo.commentFeed refreshFeedWithCompletionBlock:^(NSArray *newComments) { NSInteger rowNum = [_photoFeed indexOfPhotoModel:photo]; - PhotoTableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:rowNum inSection:0]]; + PhotoTableViewCell *cell = [_tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:rowNum inSection:0]]; if (cell) { [cell loadCommentsForPhoto:photo]; - [self.tableView beginUpdates]; - [self.tableView endUpdates]; + [_tableView beginUpdates]; + [_tableView endUpdates]; } }]; } @@ -118,13 +123,13 @@ NSInteger section = 0; NSMutableArray *indexPaths = [NSMutableArray array]; - NSUInteger newTotalNumberOfPhotos = [_photoFeed numberOfItemsInFeed]; - for (NSUInteger row = newTotalNumberOfPhotos - newPhotos.count; row < newTotalNumberOfPhotos; row++) { + NSInteger newTotalNumberOfPhotos = [_photoFeed numberOfItemsInFeed]; + for (NSInteger row = newTotalNumberOfPhotos - newPhotos.count; row < newTotalNumberOfPhotos; row++) { NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section]; [indexPaths addObject:path]; } - [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; + [_tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; } - (UIStatusBarStyle)preferredStatusBarStyle