diff options
author | Vitaly Takmazov | 2016-08-14 04:06:34 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-08-14 04:06:34 +0300 |
commit | 24214562b017cd45edc04c39daa343c57de16aaa (patch) | |
tree | 434898b690874485fa6a8ad3d8f75077a040a1a1 | |
parent | 561df6a1c494bf820c0ed7e3a5b448efd41003f2 (diff) |
new infinite scroll
-rw-r--r-- | Juick/Juick-Prefix.pch | 1 | ||||
-rw-r--r-- | Juick/MessagesViewController.h | 1 | ||||
-rw-r--r-- | Juick/MessagesViewController.m | 20 | ||||
-rw-r--r-- | Podfile | 24 | ||||
-rw-r--r-- | Podfile.lock | 8 |
5 files changed, 29 insertions, 25 deletions
diff --git a/Juick/Juick-Prefix.pch b/Juick/Juick-Prefix.pch index bd31eac..42ff0f3 100644 --- a/Juick/Juick-Prefix.pch +++ b/Juick/Juick-Prefix.pch @@ -16,6 +16,7 @@ #import <SystemConfiguration/SystemConfiguration.h> #import <MobileCoreServices/MobileCoreServices.h> #import <SDWebImage/UIImageView+WebCache.h> + #import <UIScrollView+InfiniteScroll.h> #import "NSString+HTML.h" #import "UIImage+Utils.h" #import "NSDate+TimeAgo.h" diff --git a/Juick/MessagesViewController.h b/Juick/MessagesViewController.h index b0c6a7f..38123bd 100644 --- a/Juick/MessagesViewController.h +++ b/Juick/MessagesViewController.h @@ -7,7 +7,6 @@ // #import <UIKit/UIKit.h> -#import "SVPullToRefresh.h" @interface MessagesViewController : UITableViewController<UISplitViewControllerDelegate> - (void)loadFromPath:(NSString *)messagesPath withParams:(NSDictionary *)params withTitle:(NSString *)title; diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m index 2cf4267..25622a9 100644 --- a/Juick/MessagesViewController.m +++ b/Juick/MessagesViewController.m @@ -39,14 +39,8 @@ static NSString *CellIdentifier = @"MessageCell"; [self setParams:[[NSMutableDictionary alloc] initWithDictionary:params]]; self.title = title; __weak MessagesViewController * weakSelf = self; - [self.tableView addPullToRefreshWithActionHandler:^{ - [weakSelf.messages removeAllObjects]; - [weakSelf refreshData]; - }]; - [self.tableView addInfiniteScrollingWithActionHandler:^{ - [weakSelf refreshData]; - }]; - [self.tableView triggerPullToRefresh]; + [self.messages removeAllObjects]; + [weakSelf refreshData]; } - (void) refreshData { @@ -55,6 +49,7 @@ static NSString *CellIdentifier = @"MessageCell"; [Message pullNextFromPath:self.path params:self.params callback:^(NSArray *next) { [self.messages addObjectsFromArray:next]; [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]; + [self.refreshControl performSelectorOnMainThread:@selector(endRefreshing) withObject:nil waitUntilDone:NO]; self.dataLoading = NO; }]; }); @@ -84,6 +79,15 @@ static NSString *CellIdentifier = @"MessageCell"; [self.tableView registerNib:[UINib nibWithNibName:@"MessageCell" bundle:nil] forCellReuseIdentifier:CellIdentifier]; self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.estimatedRowHeight = 500.0f; + self.refreshControl = [UIRefreshControl new]; + [self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged]; + __weak MessagesViewController * weakSelf = self; + [self.tableView addInfiniteScrollWithHandler:^(UITableView * _Nonnull tableView) { + NSNumber *lastMid = ((Message *)[weakSelf.messages lastObject]).MID; + [weakSelf.params setValue:lastMid forKey:@"before_mid"]; + [weakSelf refreshData]; + [weakSelf.tableView finishInfiniteScroll]; + }]; } - (void) composePressed { @@ -2,20 +2,20 @@ platform :ios, "9.0" target "Juick" do -pod 'MWFeedParser' -pod 'TTTAttributedLabel' -pod 'SWRevealViewController' -pod 'PDKeychainBindingsController' -pod 'RestKit', '~> 0.26.0' -pod 'SDWebImage' -pod 'FontAwesome+iOS' -pod 'NSDate+TimeAgo' -pod 'SVPullToRefresh' -pod 'SIAlertView' -pod 'XLForm' + pod 'UIScrollView-InfiniteScroll' + pod 'MWFeedParser' + pod 'TTTAttributedLabel' + pod 'SWRevealViewController' + pod 'PDKeychainBindingsController' + pod 'RestKit', '~> 0.26.0' + pod 'SDWebImage' + pod 'FontAwesome+iOS' + pod 'NSDate+TimeAgo' + pod 'SIAlertView' + pod 'XLForm' end target "JuickTests" do - + end diff --git a/Podfile.lock b/Podfile.lock index badffdb..09b8c5b 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -39,10 +39,10 @@ PODS: - SDWebImage/Core (3.8.1) - SIAlertView (1.3) - SOCKit (1.1) - - SVPullToRefresh (0.4.1) - SWRevealViewController (2.3.0) - TransitionKit (2.2.1) - TTTAttributedLabel (2.0.0) + - UIScrollView-InfiniteScroll (0.9.1) - XLForm (3.2.0) DEPENDENCIES: @@ -53,9 +53,9 @@ DEPENDENCIES: - RestKit (~> 0.26.0) - SDWebImage - SIAlertView - - SVPullToRefresh - SWRevealViewController - TTTAttributedLabel + - UIScrollView-InfiniteScroll - XLForm SPEC CHECKSUMS: @@ -70,12 +70,12 @@ SPEC CHECKSUMS: SDWebImage: 35f9627a3e44b4f292a8a8ce6a531fa488239b91 SIAlertView: 20c794b55eaf44d888773ea51647cf8907723919 SOCKit: c7376ac262bea9115b8f749358f762522a47d392 - SVPullToRefresh: ba2e718695a43253d8bea6852d2960097dc15d8c SWRevealViewController: 6d3fd97f70112fd7cef9de14df4260eacce4c63a TransitionKit: 9ceccda4cd0cdc0a05ef85eb235e5a3292c3c250 TTTAttributedLabel: 8cffe8e127e4e82ff3af1e5386d4cd0ad000b656 + UIScrollView-InfiniteScroll: 14e204c50ca4040467e1cbfa141dad7a18919b56 XLForm: 2250b4e96ab8ffa5f3355838c79edd90de451782 -PODFILE CHECKSUM: 7d654a17d555aa7dc2db35b869b150e1cdfde1d6 +PODFILE CHECKSUM: ae435862624639d3aaa4efde0455ce6631e1b0f7 COCOAPODS: 1.0.1 |