From 6062437a0fb547a25ad69e67984cf8fd97343d80 Mon Sep 17 00:00:00 2001 From: wangkeke Date: Tue, 30 Apr 2013 18:34:14 +0800 Subject: [PATCH 1/2] fix bug of loadmore --- .DS_Store | Bin 0 -> 6148 bytes ch11/.DS_Store | Bin 0 -> 6148 bytes ch11/InfiniteScrollingExample/.DS_Store | Bin 0 -> 6148 bytes .../xcdebugger/Breakpoints.xcbkptlist | 5 + .../xcschemes/iOS6InfiniteScrolling.xcscheme | 86 ++++++++++++++++++ .../xcschemes/xcschememanagement.plist | 22 +++++ .../MasterViewController.m | 2 +- .../PullToRefreshViewController.m | 40 ++++---- .../en.lproj/MainStoryboard.storyboard | 14 +-- ch11/PullToRefreshExample/.DS_Store | Bin 0 -> 6148 bytes .../xcdebugger/Breakpoints.xcbkptlist | 5 + .../xcschemes/iOS6PullToRefresh.xcscheme | 86 ++++++++++++++++++ .../xcschemes/xcschememanagement.plist | 22 +++++ 13 files changed, 253 insertions(+), 29 deletions(-) create mode 100644 .DS_Store create mode 100644 ch11/.DS_Store create mode 100644 ch11/InfiniteScrollingExample/.DS_Store create mode 100644 ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist create mode 100644 ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/iOS6InfiniteScrolling.xcscheme create mode 100644 ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 ch11/PullToRefreshExample/.DS_Store create mode 100644 ch11/PullToRefreshExample/iOS6PullToRefresh.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist create mode 100644 ch11/PullToRefreshExample/iOS6PullToRefresh.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/iOS6PullToRefresh.xcscheme create mode 100644 ch11/PullToRefreshExample/iOS6PullToRefresh.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9254c0b3358eeeac475af444ca437be07e89d4ae GIT binary patch literal 6148 zcmeH~&r8EF6vvaTYDI-!6pz94kjys7D_YL&VjYkf5`vAzrw%A z_mWhc?kpnjLGpdcdr6uPv}qV)+?z!`#vI0&4F#2>v&67_X{cqAQ8~^L&htr_$`IPG zCid3_pWR}2EM`5{`}+LhBu(<7+kNM)wzaalW`k{xM@bgRxhH2?lwbL=ocl?19|qHF z`qM0x*#q=7`Ar@v5g-CYfCvx)AYhIMdxK~Y z0U|&Iz7fFhgMfnS8m+aePX|=^`;2i56%Bm6OP~s)uF+a6M8LQn3aW>4bH(6#IP?pX z=NhfG>fwy5m0=#Ua&vj%YIW!rDxGmxE7e4R2rLq4>!yR}|2e!eOE3A0L#Rarh`>K1 zz^#El@L*HsZ2hr4JZlA%TPSFlSEB<4{=!cHH1IpJtAaW%(1$$NXss1z!G1Lylzs#h L5UPm4FA(?uyh%n> literal 0 HcmV?d00001 diff --git a/ch11/.DS_Store b/ch11/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6a16efd906b15dc3fd189426b7baabdf1a217870 GIT binary patch literal 6148 zcmeHK(QeZ)6uoW>bZkg{7-)|XPkX3P84UWsL#R5$gpj7C(jFLsq{-GuSzIM4MU<5Vqz*QT^Ba}^)>THJkH{u23d}!i*2!=_V7p>N3QK{B0UA|I>tsNf3X(-1X zIZDI)nKzJQFAk%?&z`ei_{Avi_!;-?`NaS|?DwQh;2)aN2XR;oUNmk@CU=_7)^>Z^ zbSC%P_nOY#R(m>Kfi*tXuiw1&;Bn7?GkH6G$IBss&5iAv!EaE)`DO85d0Cps^cY+f zcb&!8GDna(i4-~WA{SBv zI-RSTw63q7>nt|7Rlq9nFDjt+2M0x=Yp~SFTL&t>0sw1hW`nOj2^7aM=o&0Fq6a24 z6{xAgTrq^Equnv%T!W=XO($V4AHvKm%ne2G?1=C1a1yRYTU!OJ0`m$~_1}g%|95_V z|DPw>e^vpjz<;HHsCB(=2TL+%>(b)XS?i#@L{X;3l^U6X${fe+sH1oTg$;d6qmSad7I%s zG9YtzfD})d;St~G?;0=gxWF1`SYVFlQC>{Oc`;^$ESFpANu|P`ERk2-A>+(%_y5@N zKdk*n%s%62PF?a%GEDG}f@>*P>qcdFFPW&Fs$vTq|2`AnZO!ZjrmVBjDsRp2a-Ym7 z*}E~jR4_3Hi~(a{w;14_Ez;i)Xst0|3>X771M+`JsDeIX8Bl*6Z1f61lw+g{`*Jvx zm?WZ)SO(-1iVLB{5bEL;!-a6#lj!FomH|UJoK|L@SlPuJiqq<}C+ZI816peg7z0fP zx?wnw{r~3Y`+qaYM#g|Kuu}}UUYeytep1|9TOTKTZ9;vZiilqsunu8Iw_^IrR(wQN Zp*@if(MK!;(n7I=fYM-%G4Q7hd;#3VNt6Hp literal 0 HcmV?d00001 diff --git a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist new file mode 100644 index 0000000..05301bc --- /dev/null +++ b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/iOS6InfiniteScrolling.xcscheme b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/iOS6InfiniteScrolling.xcscheme new file mode 100644 index 0000000..b2143ca --- /dev/null +++ b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/iOS6InfiniteScrolling.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/xcschememanagement.plist b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..bba7c33 --- /dev/null +++ b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + iOS6InfiniteScrolling.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + ABC1C8B115AAD33E0033ECF0 + + primary + + + + + diff --git a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/MasterViewController.m b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/MasterViewController.m index 667a21c..b3482d8 100644 --- a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/MasterViewController.m +++ b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/MasterViewController.m @@ -41,7 +41,7 @@ -(void) doRefresh { double delayInSeconds = 2.0; dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ - self.loading = NO; + self.loading = NO; }); } diff --git a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/PullToRefreshViewController.m b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/PullToRefreshViewController.m index 583259b..04d3b5e 100755 --- a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/PullToRefreshViewController.m +++ b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/PullToRefreshViewController.m @@ -59,11 +59,13 @@ - (void)viewDidLoad self.loading = NO; - if(NSClassFromString(@"UIRefreshControl")) { - - self.refreshControl = [[UIRefreshControl alloc] init]; - [self.refreshControl addTarget:self action:@selector(refreshedByPullingTable:) forControlEvents:UIControlEventValueChanged]; - } else { +// if(NSClassFromString(@"UIRefreshControl")) { +// +// self.refreshControl = [[UIRefreshControl alloc] init]; +// [self.refreshControl addTarget:self action:@selector(refreshedByPullingTable:) forControlEvents:UIControlEventValueChanged]; +// } +// else + { self.refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tableView.bounds.size.height, self.tableView.bounds.size.width, self.tableView.bounds.size.height)]; @@ -175,18 +177,22 @@ -(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS if(indexPath.section == self.numberOfSections) { - static NSString *CellIdentifier = @"LoadingCell"; - - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - if (cell == nil) - { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; - UIActivityIndicatorView *newSpin = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; - [newSpin startAnimating]; - [newSpin setFrame:CGRectMake( 15, 12, 20, 20) ]; - [cell addSubview:newSpin]; - } - + static NSString *CellIdentifier = @"LoadingCell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) + { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; + UIActivityIndicatorView *newSpin = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; + [newSpin startAnimating]; + [newSpin setFrame:CGRectMake( 15, 12, 20, 20) ]; + [newSpin setTag:101]; + [cell addSubview:newSpin]; + } + + [(UIActivityIndicatorView *)[cell viewWithTag:101] startAnimating]; + + cell.textLabel.text = NSLocalizedString(@"Loading…", @""); cell.textLabel.textColor = [UIColor colorWithRed:0 green:0 blue:0.5 alpha:1.0]; cell.textLabel.textAlignment = NSTextAlignmentCenter; diff --git a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/en.lproj/MainStoryboard.storyboard b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/en.lproj/MainStoryboard.storyboard index 9cf339e..c837b11 100644 --- a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/en.lproj/MainStoryboard.storyboard +++ b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/en.lproj/MainStoryboard.storyboard @@ -1,7 +1,7 @@ - + - + @@ -47,17 +47,9 @@ - + - - - - - - - - diff --git a/ch11/PullToRefreshExample/.DS_Store b/ch11/PullToRefreshExample/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..04f076bb51fd3275f7936ae6927c1a87f56ed2e2 GIT binary patch literal 6148 zcmeHK!AiqG5Pe&FsCcP(5xnH+ML|LFxRfY(Qd&Pi+p1N9Db+%c`9MFwzlm>Vm(ZjY zZz4JaGjB7QnN8k?%q{@en~#rxE`SbIu(e6EM&!QeinOAqO>|mgjtp-&zzI%QqRsIe z8IZNxL5h1k;10{{cZLZ(jnI%xC=K$LBy3dgcJl$<1@k5~lc9f}L7 z#E|OZ5yORa`jZ&vBNhQeI-JhTI&o$fPbf}jr$5nfI3LigF<=bT8Q2JyUFrYlU!VW$ zNp@un7z2Nb0oP6kX^*cId+W-}Nv}<)w^R{{D*{$29B3 + + diff --git a/ch11/PullToRefreshExample/iOS6PullToRefresh.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/iOS6PullToRefresh.xcscheme b/ch11/PullToRefreshExample/iOS6PullToRefresh.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/iOS6PullToRefresh.xcscheme new file mode 100644 index 0000000..5358e85 --- /dev/null +++ b/ch11/PullToRefreshExample/iOS6PullToRefresh.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/iOS6PullToRefresh.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ch11/PullToRefreshExample/iOS6PullToRefresh.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/xcschememanagement.plist b/ch11/PullToRefreshExample/iOS6PullToRefresh.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..3ef8110 --- /dev/null +++ b/ch11/PullToRefreshExample/iOS6PullToRefresh.xcodeproj/xcuserdata/wangkeke.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + iOS6PullToRefresh.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + ABC1C8B115AAD33E0033ECF0 + + primary + + + + + From d29da06b0809cbeb4f8d03453da6c63f0a1dd3a5 Mon Sep 17 00:00:00 2001 From: Wangkeke Date: Thu, 6 Jun 2013 11:01:26 +0800 Subject: [PATCH 2/2] fix bug of refreshControl --- .../xcschemes/iOS6InfiniteScrolling.xcscheme | 86 +++++++++++++++++++ .../xcschemes/xcschememanagement.plist | 22 +++++ .../PullToRefreshViewController.m | 17 ++-- 3 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/cokecoffe.xcuserdatad/xcschemes/iOS6InfiniteScrolling.xcscheme create mode 100644 ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/cokecoffe.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/cokecoffe.xcuserdatad/xcschemes/iOS6InfiniteScrolling.xcscheme b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/cokecoffe.xcuserdatad/xcschemes/iOS6InfiniteScrolling.xcscheme new file mode 100644 index 0000000..b2143ca --- /dev/null +++ b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/cokecoffe.xcuserdatad/xcschemes/iOS6InfiniteScrolling.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/cokecoffe.xcuserdatad/xcschemes/xcschememanagement.plist b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/cokecoffe.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..bba7c33 --- /dev/null +++ b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling.xcodeproj/xcuserdata/cokecoffe.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + iOS6InfiniteScrolling.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + ABC1C8B115AAD33E0033ECF0 + + primary + + + + + diff --git a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/PullToRefreshViewController.m b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/PullToRefreshViewController.m index 04d3b5e..c898e67 100755 --- a/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/PullToRefreshViewController.m +++ b/ch11/InfiniteScrollingExample/iOS6InfiniteScrolling/PullToRefreshViewController.m @@ -59,12 +59,12 @@ - (void)viewDidLoad self.loading = NO; -// if(NSClassFromString(@"UIRefreshControl")) { -// -// self.refreshControl = [[UIRefreshControl alloc] init]; -// [self.refreshControl addTarget:self action:@selector(refreshedByPullingTable:) forControlEvents:UIControlEventValueChanged]; -// } -// else + if(NSClassFromString(@"UIRefreshControl")) { + + self.refreshControl = [[UIRefreshControl alloc] init]; + [self.refreshControl addTarget:self action:@selector(refreshedByPullingTable:) forControlEvents:UIControlEventValueChanged]; + } + else { self.refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tableView.bounds.size.height, self.tableView.bounds.size.width, self.tableView.bounds.size.height)]; @@ -78,7 +78,7 @@ - (void)viewDidLoad - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if(self.searchDisplayController.searchResultsTableView == scrollView) return; - + if(NSClassFromString(@"UIRefreshControl")) return; if (self.refreshHeaderView.state == EGOOPullRefreshLoading) { CGFloat offset = MAX(scrollView.contentOffset.y * -1, 0); offset = MIN(offset, 60); @@ -99,7 +99,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { if(self.searchDisplayController.searchResultsTableView == scrollView) return; - + if(NSClassFromString(@"UIRefreshControl")) return; if (scrollView.contentOffset.y <= - 65.0f && !self.loading) { self.loading = YES; @@ -138,6 +138,7 @@ -(void) loadMore { -(void) setLoading:(BOOL)loading { + if(NSClassFromString(@"UIRefreshControl")) return; _loading = loading; [UIView beginAnimations:nil context:NULL];