Update with ContentSize

This commit is contained in:
Kyle Fang
2013-02-27 10:58:09 +08:00
parent fccdd0c004
commit 67e8db2e5d
3 changed files with 51 additions and 12 deletions

View File

@@ -7,7 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
040E055516DD864D00E0731D /* UIScrollView+ZGPullDrag.m in Sources */ = {isa = PBXBuildFile; fileRef = 040E055416DD864D00E0731D /* UIScrollView+ZGPullDrag.m */; };
040E055816DD8EF900E0731D /* UIScrollView+ZGPullDrag.m in Sources */ = {isa = PBXBuildFile; fileRef = 040E055716DD8EF900E0731D /* UIScrollView+ZGPullDrag.m */; };
041C811716DB0DFB0034A3A8 /* GVUserDefaults+Progress.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FD824616DB02910028AF2A /* GVUserDefaults+Progress.m */; };
041C811B16DB0EAD0034A3A8 /* PPEvenKitManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FD824116DAFB770028AF2A /* PPEvenKitManager.m */; };
041C811E16DB0F080034A3A8 /* PPEvenKitManagerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 041C811D16DB0F080034A3A8 /* PPEvenKitManagerTest.m */; };
@@ -51,8 +51,8 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
040E055316DD864D00E0731D /* UIScrollView+ZGPullDrag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+ZGPullDrag.h"; sourceTree = "<group>"; };
040E055416DD864D00E0731D /* UIScrollView+ZGPullDrag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+ZGPullDrag.m"; sourceTree = "<group>"; };
040E055616DD8EF900E0731D /* UIScrollView+ZGPullDrag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+ZGPullDrag.h"; sourceTree = "<group>"; };
040E055716DD8EF900E0731D /* UIScrollView+ZGPullDrag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+ZGPullDrag.m"; sourceTree = "<group>"; };
041C811C16DB0F080034A3A8 /* PPEvenKitManagerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PPEvenKitManagerTest.h; sourceTree = "<group>"; };
041C811D16DB0F080034A3A8 /* PPEvenKitManagerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PPEvenKitManagerTest.m; sourceTree = "<group>"; };
04386A0B16908C4C0058C876 /* Progress.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Progress.entitlements; sourceTree = "<group>"; };
@@ -161,12 +161,12 @@
04BDDECA16902D0900D04A9E /* Progress */ = {
isa = PBXGroup;
children = (
040E055316DD864D00E0731D /* UIScrollView+ZGPullDrag.h */,
040E055416DD864D00E0731D /* UIScrollView+ZGPullDrag.m */,
048D437016DBC4E000A40CB1 /* ReminderItemCell.h */,
048D437116DBC4E000A40CB1 /* ReminderItemCell.m */,
048D433E16DB9D5300A40CB1 /* PPRemindersViewController.h */,
048D433F16DB9D5400A40CB1 /* PPRemindersViewController.m */,
040E055616DD8EF900E0731D /* UIScrollView+ZGPullDrag.h */,
040E055716DD8EF900E0731D /* UIScrollView+ZGPullDrag.m */,
04FD824516DB02910028AF2A /* GVUserDefaults+Progress.h */,
04FD824616DB02910028AF2A /* GVUserDefaults+Progress.m */,
04FD824016DAFB770028AF2A /* PPEvenKitManager.h */,
@@ -370,7 +370,7 @@
04FD824716DB02910028AF2A /* GVUserDefaults+Progress.m in Sources */,
048D434016DB9D5400A40CB1 /* PPRemindersViewController.m in Sources */,
048D437216DBC4E000A40CB1 /* ReminderItemCell.m in Sources */,
040E055516DD864D00E0731D /* UIScrollView+ZGPullDrag.m in Sources */,
040E055816DD8EF900E0731D /* UIScrollView+ZGPullDrag.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -77,6 +77,9 @@ static NSString *CellIdentifier = @"ReminderCell";
if (!_placeHolderCell) {
_placeHolderCell = [[UITableViewCell alloc] initWithFrame:CGRectZero];
_placeHolderCell.frame = CGRectMake(0, 0, self.view.frame.size.width, self.tableView.rowHeight);
UIView *seperator = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 1.f)];
seperator.backgroundColor = self.tableView.separatorColor;
[_placeHolderCell addSubview:seperator];
}
return _placeHolderCell;
}
@@ -136,4 +139,25 @@ static NSString *CellIdentifier = @"ReminderCell";
[[PPEvenKitManager sharedManager] deleteReminder:reminder];
}
#pragma mark - ScrollView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
[self touchPointUpdate:[touches anyObject]];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesMoved:touches withEvent:event];
[self touchPointUpdate:[touches anyObject]];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesEnded:touches withEvent:event];
[self touchPointUpdate:[touches anyObject]];
}
- (void)touchPointUpdate:(UITouch *)touch{
NSLog(@"AwesomE");
}
@end

View File

@@ -34,6 +34,7 @@ static char UIScrollViewWasDragging;
}
} else if (self.isObserving == NO && isObserving == YES) {
[self addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
}
[self willChangeValueForKey:@"isObserving"];
@@ -116,18 +117,23 @@ static char UIScrollViewWasDragging;
- (void)addZGDragView:(UIView *)dragView{
if (self.dragView != dragView) {
[self.dragView removeFromSuperview];
[self layoutIfNeeded];
CGFloat originY = MAX(self.frame.size.height, self.contentSize.height);
dragView.frame = CGRectOffset(dragView.frame, -dragView.frame.origin.x, -dragView.frame.origin.y+originY);
[self addSubview:dragView];
self.dragView = dragView;
self.isObserving = YES;
} else {
CGFloat originY = MAX(self.frame.size.height, self.contentSize.height);
dragView.frame = CGRectOffset(dragView.frame, -dragView.frame.origin.x, -dragView.frame.origin.y+originY);
}
[self layoutIfNeeded];
CGFloat originY = MAX(self.frame.size.height, self.contentSize.height);
dragView.frame = CGRectOffset(dragView.frame, -dragView.frame.origin.x, -dragView.frame.origin.y+originY);
[self addSubview:dragView];
self.dragView = dragView;
self.isObserving = YES;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
if ([keyPath isEqualToString:@"contentOffset"]) {
[self scrollViewDidScroll:[[change valueForKey:NSKeyValueChangeNewKey] CGPointValue]];
} else if ([keyPath isEqualToString:@"contentSize"]) {
[self contentSizeDidUpdate:[[change valueForKey:NSKeyValueChangeNewKey] CGSizeValue]];
}
}
@@ -148,6 +154,15 @@ static char UIScrollViewWasDragging;
self.wasDragging = self.isDragging;
}
- (void)contentSizeDidUpdate:(CGSize )contenSize{
if (self.dragView) {
[self addZGDragView:self.dragView];
}
}
- (void)pullViewHandler:(CGFloat )visiblePixels{
if ([self.pullDragDelegate respondsToSelector:@selector(pullView:Show:ofTotal:)]) {
[self.pullDragDelegate pullView:self.pullView Show:visiblePixels ofTotal:self.pullView.frame.size.height];