Skip to content

Commit

Permalink
"运行时"添加一些注释
Browse files Browse the repository at this point in the history
  • Loading branch information
BigShow1949 committed Mar 27, 2018
1 parent 652d034 commit fecfc3b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@
/**设置点击时间间隔*/
@property (nonatomic, assign) NSTimeInterval timeInterval;
@end
// 版权属于原作者
// http://code4app.com (cn) http://code4app.net (en)
// 发布代码于最专业的源码分享网站: Code4App.com

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ + (void)load{
dispatch_once(&onceToken, ^{
SEL selA = @selector(sendAction:to:forEvent:);
SEL selB = @selector(mySendAction:to:forEvent:); // B是自己定义的方法
Method methodA = class_getInstanceMethod(self,selA);
Method methodA = class_getInstanceMethod(self, selA);
Method methodB = class_getInstanceMethod(self, selB);
BOOL isAdd = class_addMethod(self, selA, method_getImplementation(methodB), method_getTypeEncoding(methodB));
if (isAdd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @implementation YFButtonViewController
- (void)viewDidLoad {
[super viewDidLoad];

// 避免按钮多次点击的三种实现方法
[self setupDataArr:@[@[@"多次点击按钮",@"YFMultipleClicksViewController"],
@[@"微信注册按钮",@"YFAnimationCircleButtonVC"],
@[@"ape展开按钮",@"YFBubbleMenuButtonViewController"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (void)viewDidLoad {

[self KVCtoModel];

// [self printValue];
[self printValue];

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,37 @@ + (void)load
// 不能在分类中重写系统方法imageNamed,因为会把系统的功能给覆盖掉,而且分类中不能调用super.

// 既能加载图片又能打印
// 场景1: 如果本地图片 图片如果写错了,会有提示
//+ (instancetype)imageWithName:(NSString *)name
//{
// // 这里调用imageWithName,相当于调用imageName
// UIImage *image = [self imageWithName:name];
//
// if (image == nil) {
// NSLog(@"ERROR:加载空的图片");
// }
//
// return image;
//}

// 场景2:所有图片的名称都拼接_os7的话,当旧项目需要更改一套图片时,可以避免一个个更改
// NSString *newName = [name stringByAppendingString:@"_os7"];
+ (instancetype)imageWithName:(NSString *)name
{
BOOL img_iOS7 = [[UIDevice currentDevice].systemVersion floatValue] >= 7.0;
UIImage *image = nil;
if (img_iOS7) {
NSString *newName = [name stringByAppendingString:@"_os7"];
image = [UIImage imageWithName:newName];//这里实际调用的时系统方法imageNamed:
}

// 这里调用imageWithName,相当于调用imageName
UIImage *image = [self imageWithName:name];
if (image == nil) { // _os7 图片没有就还是显示原来的图片
image = [UIImage imageWithName:name];
}

if (image == nil) {
if (image == nil) { // 图片还是没有,就报错提示
NSLog(@"ERROR:加载空的图片");
}

return image;
}

Expand Down

0 comments on commit fecfc3b

Please sign in to comment.