Permalink
Browse files

move bottom pull view when scroll view's content size changes

  • Loading branch information...
chrispix committed Jan 3, 2012
1 parent a69c015 commit f03c0340ceb6ef1da16f1f581c9cbf98246a8903
View
@@ -90,6 +90,7 @@ - (id)initWithScrollView:(UIScrollView *)scroll atBottom:(BOOL)atBottom {
isBottom = atBottom;
self.scrollView = scroll;
[scrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:NULL];
+ [scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:NULL];
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.backgroundColor = [UIColor colorWithRed:226.0/255.0 green:231.0/255.0 blue:237.0/255.0 alpha:1.0];
@@ -149,6 +150,12 @@ - (id)initWithWebView:(UIWebView *)webView atBottom:(BOOL)atBottom {
return [self initWithScrollView:currentScrollView atBottom:atBottom];
}
+- (void)updatePosition {
+ if (isBottom) {
+ self.frame = CGRectMake(0.0f, self.scrollView.contentSize.height, self.scrollView.bounds.size.width, self.scrollView.bounds.size.height);
+ }
+}
+
#pragma mark -
#pragma mark Setters
@@ -293,6 +300,8 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
[delegate pullToRefreshViewShouldRefresh:self];
}
}
+ } else if ([keyPath isEqualToString:@"contentSize"]) {
+ [self updatePosition];
}
}
@@ -329,6 +338,7 @@ - (void)timerExpired:(NSTimer*)theTimer {
- (void)dealloc {
[scrollView removeObserver:self forKeyPath:@"contentOffset"];
+ [scrollView removeObserver:self forKeyPath:@"contentSize"];
[scrollView release];
[arrowImage release];
[activityView release];
@@ -16,7 +16,8 @@
@property(assign)PullToRefreshView *bottomPull;
-(IBAction)didTapFinishedLoading:(id)sender;
-- (IBAction)didTapFinishLoadingTop:(id)sender;
-- (IBAction)didTapFinishLoadingBottom:(id)sender;
+-(IBAction)didTapFinishLoadingTop:(id)sender;
+-(IBAction)didTapFinishLoadingBottom:(id)sender;
+-(IBAction)didTapMakeContentSizeTaller:(id)sender;
@end
@@ -53,6 +53,10 @@ -(IBAction)didTapFinishLoadingBottom:(id)sender {
[self.bottomPull finishedLoading];
}
+-(IBAction)didTapMakeContentSizeTaller:(id)sender {
+ self.scrollView.contentSize = CGSizeMake(self.scrollView.contentSize.width, self.scrollView.contentSize.height + 20);
+}
+
#pragma mark -
#pragma mark PullToRefreshViewDelegate
@@ -96,7 +96,7 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{57, 211}, {208, 37}}</string>
<reference key="NSSuperview" ref="1016583224"/>
- <reference key="NSNextKeyView" ref="77952817"/>
+ <reference key="NSNextKeyView" ref="631923911"/>
<string key="NSReuseIdentifierKey">_NS:225</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -170,6 +170,28 @@
<reference key="IBUIFontDescription" ref="680852631"/>
<reference key="IBUIFont" ref="227969696"/>
</object>
+ <object class="IBUIButton" id="631923911">
+ <reference key="NSNextResponder" ref="1016583224"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{64, 256}, {193, 37}}</string>
+ <reference key="NSSuperview" ref="1016583224"/>
+ <reference key="NSNextKeyView" ref="77952817"/>
+ <string key="NSReuseIdentifierKey">_NS:225</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <int key="IBUIButtonType">1</int>
+ <string key="IBUINormalTitle">Make contentSize taller</string>
+ <reference key="IBUIHighlightedTitleColor" ref="905454287"/>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <reference key="IBUINormalTitleShadowColor" ref="157889243"/>
+ <reference key="IBUIFontDescription" ref="680852631"/>
+ <reference key="IBUIFont" ref="227969696"/>
+ </object>
</array>
<string key="NSFrameSize">{320, 460}</string>
<reference key="NSSuperview" ref="774585933"/>
@@ -244,6 +266,15 @@
</object>
<int key="connectionID">17</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">didTapMakeContentSizeTaller:</string>
+ <reference key="source" ref="631923911"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">19</int>
+ </object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -281,6 +312,7 @@
<reference ref="4623693"/>
<reference ref="928954653"/>
<reference ref="77952817"/>
+ <reference ref="631923911"/>
</array>
<reference key="parent" ref="774585933"/>
</object>
@@ -309,6 +341,11 @@
<reference key="object" ref="77952817"/>
<reference key="parent" ref="1016583224"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">18</int>
+ <reference key="object" ref="631923911"/>
+ <reference key="parent" ref="1016583224"/>
+ </object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -320,6 +357,7 @@
<string key="12.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="14.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="15.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="18.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="8.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="9.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -328,7 +366,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">17</int>
+ <int key="maxID">19</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>

0 comments on commit f03c034

Please sign in to comment.