-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [ios] Stupid scoll view, always reset content offset to zero after …
…insert cells, fixed it by hooking
- Loading branch information
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Created by Weex. | ||
* Copyright (c) 2016, Alibaba, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the Apache Licence 2.0. | ||
* For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSObject (WXSwizzle) | ||
|
||
+ (BOOL)weex_swizzle:(Class)originalClass Method:(SEL)originalSelector withMethod:(SEL)swizzledSelector; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Created by Weex. | ||
* Copyright (c) 2016, Alibaba, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the Apache Licence 2.0. | ||
* For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "NSObject+WXSwizzle.h" | ||
#import <objc/runtime.h> | ||
|
||
@implementation NSObject (WXSwizzle) | ||
|
||
+ (BOOL)weex_swizzle:(Class)originalClass Method:(SEL)originalSelector withMethod:(SEL)swizzledSelector | ||
{ | ||
if (!(originalClass && originalSelector && swizzledSelector)) { | ||
return NO; | ||
} | ||
|
||
Class class = [self class]; | ||
|
||
Method originalMethod = class_getInstanceMethod(originalClass, originalSelector); | ||
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); | ||
|
||
BOOL didAddMethod = class_addMethod(originalClass, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); | ||
|
||
if (didAddMethod) { | ||
class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); | ||
} else { | ||
method_exchangeImplementations(originalMethod, swizzledMethod); | ||
} | ||
|
||
return YES; | ||
} | ||
|
||
@end |