Skip to content

Commit 14203ca

Browse files
committed
done for web view
1 parent a58deaf commit 14203ca

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
DictionaryPullDownToClose.xcodeproj/project.xcworkspace/xcuserdata/everettjf.xcuserdatad/UserInterfaceState.xcuserstate

DictionaryPullDownToClose/DictionaryPullDownToClose.mm

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// 5. (optionally) call old method using CHSuper()
2626

2727
static CGFloat kThreshold = 80;
28+
2829
static CGFloat sCurrentYOffset = 0;
2930
static CGFloat sBeginYOffset = 0;
3031
static CGFloat sEndYOffset = 0;
@@ -38,11 +39,11 @@ @interface DDParsecTableViewController : UITableViewController
3839
@class DDParsecTableViewController;
3940
CHDeclareClass(DDParsecTableViewController); // declare class
4041

41-
CHOptimizedMethod(1, self, void, DDParsecTableViewController, viewWillAppear,BOOL,value1)
42+
CHOptimizedMethod(1, self, void, DDParsecTableViewController, viewDidAppear,BOOL,value1)
4243
{
4344
sContainerView = self.view;
44-
NSLog(@"qiweidict : view will appear");
45-
CHSuper(1, DDParsecTableViewController, viewWillAppear, value1);
45+
NSLog(@"qiweidict : first page viewDidAppear %@",self);
46+
CHSuper(1, DDParsecTableViewController, viewDidAppear, value1);
4647
}
4748

4849
//////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -106,14 +107,50 @@ - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoi
106107

107108
@end
108109

110+
///////////////////////////////////////////////////////////////////////////////////////////////////
111+
112+
@interface DUEntryViewController : UIViewController<UIScrollViewDelegate>
113+
@end
114+
115+
@interface DUEntryViewController (dictionarypulldowntoclose)
116+
@end
117+
@implementation DUEntryViewController (dictionarypulldowntoclose)
118+
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
119+
NSLog(@"qiweidict: did scroll : %@",@(scrollView.contentOffset.y));
120+
}
121+
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
122+
}
123+
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
124+
}
125+
@end
126+
127+
@class DUEntryViewController;
128+
CHDeclareClass(DUEntryViewController); // declare class
129+
130+
CHOptimizedMethod(0, self, void, DUEntryViewController, viewDidLoad)
131+
{
132+
NSLog(@"qiweidict : detail viewDidLoad %p %@",self,self);
133+
CHSuper(0, DUEntryViewController, viewDidLoad);
134+
135+
UIView *view = self.view;
136+
if(view.subviews.count > 0){
137+
UIWebView *webView = view.subviews[0];
138+
webView.scrollView.delegate = self;
139+
}
140+
}
141+
142+
///////////////////////////////////////////////////////////////////////////////////////////////////
143+
109144
CHConstructor // code block that runs immediately upon load
110145
{
111146
@autoreleasepool
112147
{
113148
CHLoadLateClass(DDParsecTableViewController);
114149
CHLoadLateClass(DDParsecServiceCollectionViewController);
150+
CHLoadLateClass(DUEntryViewController);
115151

116-
CHHook(1, DDParsecTableViewController, viewWillAppear);
152+
CHHook(1, DDParsecTableViewController, viewDidAppear);
117153
CHHook(1, DDParsecServiceCollectionViewController, scrollViewDidScroll); // register hook
154+
CHHook(0, DUEntryViewController, viewDidLoad);
118155
}
119156
}

0 commit comments

Comments
 (0)