源码-03-九宫格 封装 懒加载 plist

九空格雏形--

每一行的列数,行间距,列间距

%决定了列数,/决定了行数。->来计算每个格子的x和y的位置;

 1 #import "ViewController.h"
 2
 3 @interface ViewController ()
 4 @property (weak, nonatomic) IBOutlet UIView *shopsView;
 5 @end
 6
 7 @implementation ViewController
 8
 9 - (void)viewDidLoad
10 {
11     [super viewDidLoad];
12
13     [self addButtonWithImage:@"add" highImage:@"add_highlighted" disableImage:@"add_disabled"                frame:CGRectMake(30, 30, 50, 50) action:@selector(add)];
14     [self addButtonWithImage:@"remove" highImage:@"remove_highlighted" disableImage:@"remove_disabled"                frame:CGRectMake(270, 30, 50, 50) action:@selector(remove)];
15 }
16
17 #pragma mark 添加按钮
18 - (void)addButtonWithImage:(NSString *)image highImage:(NSString *)highImage disableImage:(NSString *)disableImage frame:(CGRect)frame action:(SEL)action
19 {
20     // 创建按钮
21     UIButton *btn = [[UIButton alloc] init];
22     // 设置背景图片
23     [btn setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
24     [btn setBackgroundImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
25     [btn setBackgroundImage:[UIImage imageNamed:disableImage] forState:UIControlStateDisabled];
26     // 设置位置和尺寸
27     btn.frame = frame;
28     // 监听按钮点击
29     [btn addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
30
31     // 添加按钮
32     [self.view addSubview:btn];
33 }
34
35 #pragma mark 添加
36 - (void)add
37 {
38 //    self.shopsView.clipsToBounds = YES;
39
40     // 每一个商品的尺寸
41     CGFloat shopW = 50;
42     CGFloat shopH = 70;
43
44     // 一行的列数
45     int cols = 4;
46
47     // 每一列之间的间距
48     CGFloat colMargin = (self.shopsView.frame.size.width - cols * shopW) / (cols - 1);
49     // 每一行之间的间距
50     CGFloat rowMargin = 10;
51
52     // 创建一个父控件(整体:存放图片和文字)
53     UIView *shopView = [[UIView alloc] init];
54     shopView.backgroundColor = [UIColor redColor];
55
56     // 商品的索引
57     NSUInteger index = self.shopsView.subviews.count;
58
59     // 商品的x值
60     NSUInteger col = index % cols;
61     CGFloat shopX = col * (shopW + colMargin);
62
63     // 商品的y值
64     NSUInteger row = index / cols;
65     CGFloat shopY = row * (shopH + rowMargin);
66
67     shopView.frame = CGRectMake(shopX, shopY, shopW, shopH);
68     [self.shopsView addSubview:shopView];
69
70     // 添加图片
71     UIImageView *iconView = [[UIImageView alloc] init];
72     iconView.image = [UIImage imageNamed:@"danjianbao"];
73     iconView.frame = CGRectMake(0, 0, shopW, shopW);
74     iconView.backgroundColor = [UIColor blueColor];
75     [shopView addSubview:iconView];
76
77     // 添加文字
78     UILabel *label = [[UILabel alloc] init];
79     label.text = @"单肩包";
80     label.frame = CGRectMake(0, shopW, shopW, shopH - shopW);
81     label.font = [UIFont systemFontOfSize:11];
82     label.textAlignment = NSTextAlignmentCenter;
83     [shopView addSubview:label];
84 }
85
86 #pragma mark 删除
87 - (void)remove
88 {
89     NSLog(@"删除。。。。");
90 }
91
92 @end

启用活的数据(存有字典的数组)

  1 #import "ViewController.h"
  2
  3 @interface ViewController ()
  4 /** 存放所有商品的整体 */
  5 @property (weak, nonatomic) IBOutlet UIView *shopsView;
  6 // 文档注释
  7 /** 添加按钮 */
  8 @property (weak, nonatomic) UIButton *addBtn;
  9 /** 删除按钮 */
 10 @property (weak, nonatomic) UIButton *removeBtn;
 11
 12 /** 全部商品数据 */
 13 @property (strong, nonatomic) NSArray *shops;
 14 @end
 15
 16 @implementation ViewController
 17
 18 - (void)viewDidLoad
 19 {
 20     [super viewDidLoad];
 21
 22     // 添加“添加按钮”
 23     self.addBtn = [self addButtonWithImage:@"add" highImage:@"add_highlighted" disableImage:@"add_disabled"                           frame:CGRectMake(30, 30, 50, 50) action:@selector(add)];
 24
 25     // 添加“删除按钮”
 26     self.removeBtn = [self addButtonWithImage:@"remove" highImage:@"remove_highlighted" disableImage:@"remove_disabled"                           frame:CGRectMake(270, 30, 50, 50) action:@selector(remove)];
 27     self.removeBtn.enabled = NO;
 28
 29
 30     // 数据
 31     self.shops = @[
 32                        @{
 33                            @"icon" : @"danjianbao",
 34                            @"name" : @"单肩包"
 35                            },
 36                        @{
 37                            @"icon" : @"liantiaobao",
 38                            @"name" : @"链条包"
 39                            },
 40                        @{
 41                            @"icon" : @"qianbao",
 42                            @"name" : @"钱包"
 43                            },
 44                        @{
 45                            @"name" : @"手提包",
 46                            @"icon" : @"shoutibao.png"
 47                            },
 48                        @{
 49                            @"name" : @"双肩包",
 50                            @"icon" : @"shuangjianbao.png"
 51                            },
 52                        @{
 53                            @"name" : @"斜挎包",
 54                            @"icon" : @"xiekuabao.png"
 55                            }
 56                        ];
 57 }
 58
 59 #pragma mark 添加按钮
 60 - (UIButton *)addButtonWithImage:(NSString *)image highImage:(NSString *)highImage disableImage:(NSString *)disableImage                      frame:(CGRect)frame action:(SEL)action
 61 {
 62     // 创建按钮
 63     UIButton *btn = [[UIButton alloc] init];
 64     // 设置背景图片
 65     [btn setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
 66     [btn setBackgroundImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
 67     [btn setBackgroundImage:[UIImage imageNamed:disableImage] forState:UIControlStateDisabled];
 68     // 设置位置和尺寸
 69     btn.frame = frame;
 70     // 监听按钮点击
 71     [btn addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
 72     // 添加按钮
 73     [self.view addSubview:btn];
 74     return btn;
 75 }
 76
 77 #pragma mark 添加
 78 - (void)add
 79 {
 80 //    self.shopsView.clipsToBounds = YES;
 81
 82     // 每一个商品的尺寸
 83     CGFloat shopW = 80;
 84     CGFloat shopH = 90;
 85
 86     // 一行的列数
 87     int cols = 3;
 88
 89     // 每一列之间的间距
 90     CGFloat colMargin = (self.shopsView.frame.size.width - cols * shopW) / (cols - 1);
 91     // 每一行之间的间距
 92     CGFloat rowMargin = 10;
 93
 94     // 创建一个父控件(整体:存放图片和文字)
 95     UIView *shopView = [[UIView alloc] init];
 96     shopView.backgroundColor = [UIColor redColor];
 97
 98     // 商品的索引
 99     NSUInteger index = self.shopsView.subviews.count;
100
101     // 商品的x值
102     NSUInteger col = index % cols;
103     CGFloat shopX = col * (shopW + colMargin);
104
105     // 商品的y值
106     NSUInteger row = index / cols;
107     CGFloat shopY = row * (shopH + rowMargin);
108
109     shopView.frame = CGRectMake(shopX, shopY, shopW, shopH);
110     [self.shopsView addSubview:shopView];
111
112     // 获得index位置对应的商品数据
113     NSDictionary *shop = self.shops[index];
114
115     // 添加图片
116     UIImageView *iconView = [[UIImageView alloc] init];
117     iconView.image = [UIImage imageNamed:shop[@"icon"]];
118     iconView.frame = CGRectMake(0, 0, shopW, shopW);
119     iconView.backgroundColor = [UIColor blueColor];
120     [shopView addSubview:iconView];
121
122     // 添加文字
123     UILabel *label = [[UILabel alloc] init];
124     label.text = shop[@"name"];
125     label.frame = CGRectMake(0, shopW, shopW, shopH - shopW);
126     label.font = [UIFont systemFontOfSize:11];
127     label.textAlignment = NSTextAlignmentCenter;
128     [shopView addSubview:label];
129
130     // 控制按钮的可用性
131     [self checkState];
132
133     // 设置“添加按钮”能不能点击
134 //    if (self.shopsView.subviews.count == shops.count) {
135 //        // 添加满了
136 //        self.addBtn.enabled = NO;
137 //    }
138 //
139 //    self.removeBtn.enabled = YES;
140 }
141
142 #pragma mark 删除
143 - (void)remove
144 {
145     [[self.shopsView.subviews lastObject] removeFromSuperview];
146
147     // 控制按钮的可用性
148     [self checkState];
149
150     // 设置“删除按钮”能不能点击
151 //    if (self.shopsView.subviews.count == 0) {
152 //        // 全部被删掉了
153 //        self.removeBtn.enabled = NO;
154 //    }
155 //
156 //    self.addBtn.enabled = YES;
157 }
158
159 #pragma mark 检查状态:按钮状态
160 - (void)checkState
161 {
162 //    if (self.shopsView.subviews.count == 0) {
163 //        self.removeBtn.enabled = NO;
164 //    } else {
165 //        self.removeBtn.enabled = YES;
166 //    }
167 //
168     // 删除按钮什么时候可以点击:商品个数 > 0
169     self.removeBtn.enabled = (self.shopsView.subviews.count > 0);
170
171 //    if (self.shopsView.subviews.count == self.shops.count) {
172 //        self.addBtn.enabled = NO;
173 //    } else {
174 //        self.addBtn.enabled = YES;
175 //    }
176     // 添加按钮什么时候可以点击:商品个数 < 总数
177     self.addBtn.enabled = (self.shopsView.subviews.count < self.shops.count);
178 }
179
180 @end

添加指示器,定时器方法

  1 #import "ViewController.h"
  2
  3 @interface ViewController ()
  4 /** 存放所有商品的整体 */
  5 @property (weak, nonatomic) IBOutlet UIView *shopsView;
  6
  7 /** HUD */
  8 @property (weak, nonatomic) IBOutlet UILabel *hud;
  9
 10 // 文档注释
 11 /** 添加按钮 */
 12 @property (weak, nonatomic) UIButton *addBtn;
 13 /** 删除按钮 */
 14 @property (weak, nonatomic) UIButton *removeBtn;
 15
 16 /** 全部商品数据 */
 17 @property (strong, nonatomic) NSArray *shops;
 18 @end
 19
 20 @implementation ViewController
 21
 22 - (void)viewDidLoad
 23 {
 24     [super viewDidLoad];
 25
 26     // 添加“添加按钮”
 27     self.addBtn = [self addButtonWithImage:@"add" highImage:@"add_highlighted" disableImage:@"add_disabled"                         frame:CGRectMake(30, 30, 50, 50) action:@selector(add)];
 28
 29     // 添加“删除按钮”
 30     self.removeBtn = [self addButtonWithImage:@"remove" highImage:@"remove_highlighted" disableImage:@"remove_disabled"                           frame:CGRectMake(270, 30, 50, 50) action:@selector(remove)];
 31     self.removeBtn.enabled = NO;
 32
 33
 34     // 数据
 35     self.shops = @[
 36                        @{
 37                            @"icon" : @"danjianbao",
 38                            @"name" : @"单肩包"
 39                            },
 40                        @{
 41                            @"icon" : @"liantiaobao",
 42                            @"name" : @"链条包"
 43                            },
 44                        @{
 45                            @"icon" : @"qianbao",
 46                            @"name" : @"钱包"
 47                            },
 48                        @{
 49                            @"name" : @"手提包",
 50                            @"icon" : @"shoutibao.png"
 51                            },
 52                        @{
 53                            @"name" : @"双肩包",
 54                            @"icon" : @"shuangjianbao.png"
 55                            },
 56                        @{
 57                            @"name" : @"斜挎包",
 58                            @"icon" : @"xiekuabao.png"
 59                            }
 60                        ];
 61 }
 62
 63 #pragma mark 添加按钮
 64 - (UIButton *)addButtonWithImage:(NSString *)image highImage:(NSString *)highImage disableImage:(NSString *)disableImage                   frame:(CGRect)frame action:(SEL)action
 65 {
 66     // 创建按钮
 67     UIButton *btn = [[UIButton alloc] init];
 68     // 设置背景图片
 69     [btn setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
 70     [btn setBackgroundImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
 71     [btn setBackgroundImage:[UIImage imageNamed:disableImage] forState:UIControlStateDisabled];
 72     // 设置位置和尺寸
 73     btn.frame = frame;
 74     // 监听按钮点击
 75     [btn addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
 76     // 添加按钮
 77     [self.view addSubview:btn];
 78     return btn;
 79 }
 80
 81 #pragma mark 添加
 82 - (void)add
 83 {
 84 //    self.shopsView.clipsToBounds = YES;
 85
 86     // 每一个商品的尺寸
 87     CGFloat shopW = 80;
 88     CGFloat shopH = 90;
 89
 90     // 一行的列数
 91     int cols = 3;
 92
 93     // 每一列之间的间距
 94     CGFloat colMargin = (self.shopsView.frame.size.width - cols * shopW) / (cols - 1);
 95     // 每一行之间的间距
 96     CGFloat rowMargin = 10;
 97
 98     // 创建一个父控件(整体:存放图片和文字)
 99     UIView *shopView = [[UIView alloc] init];
100     shopView.backgroundColor = [UIColor redColor];
101
102     // 商品的索引
103     NSUInteger index = self.shopsView.subviews.count;
104
105     // 商品的x值
106     NSUInteger col = index % cols;
107     CGFloat shopX = col * (shopW + colMargin);
108
109     // 商品的y值
110     NSUInteger row = index / cols;
111     CGFloat shopY = row * (shopH + rowMargin);
112
113     shopView.frame = CGRectMake(shopX, shopY, shopW, shopH);
114     [self.shopsView addSubview:shopView];
115
116     // 获得index位置对应的商品数据
117     NSDictionary *shop = self.shops[index];
118
119     // 添加图片
120     UIImageView *iconView = [[UIImageView alloc] init];
121     iconView.image = [UIImage imageNamed:shop[@"icon"]];
122     iconView.frame = CGRectMake(0, 0, shopW, shopW);
123     iconView.backgroundColor = [UIColor blueColor];
124     [shopView addSubview:iconView];
125
126     // 添加文字
127     UILabel *label = [[UILabel alloc] init];
128     label.text = shop[@"name"];
129     label.frame = CGRectMake(0, shopW, shopW, shopH - shopW);
130     label.font = [UIFont systemFontOfSize:11];
131     label.textAlignment = NSTextAlignmentCenter;
132     [shopView addSubview:label];
133
134     // 控制按钮的可用性
135     [self checkState];
136 }
137
138 #pragma mark 删除
139 - (void)remove
140 {
141     [[self.shopsView.subviews lastObject] removeFromSuperview];
142
143     // 控制按钮的可用性
144     [self checkState];
145 }
146
147 #pragma mark 检查状态:按钮状态
148 - (void)checkState
149 {
150     // 删除按钮什么时候可以点击:商品个数 > 0
151     self.removeBtn.enabled = (self.shopsView.subviews.count > 0);
152     // 添加按钮什么时候可以点击:商品个数 < 总数
153     self.addBtn.enabled = (self.shopsView.subviews.count < self.shops.count);
154
155     // 显示HUD
156     NSString *text = nil;
157     if (self.removeBtn.enabled == NO) { // 删光了
158         text = @"已经全部删除";
159     } else if (self.addBtn.enabled == NO) { // 加满了
160         text = @"已经添加满了";
161     }
162     if (text == nil) return;
163
164     self.hud.text = text;
165     self.hud.alpha = 1.0;
166     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
167         self.hud.alpha = 0.0;
168     });
169 }
170
171 #pragma mark  隐藏HUD
172 //- (void)hideHUD
173 //{
174 //    self.hud.alpha = 0.0;
175 //}
177 // HUD
178 // 指示器
179 // 蒙板
180 // 遮盖
181
182
183 // 定时任务
184 // SEL:对方法的包装, 使用@selector(方法名)包装一个SEL数据
185 // 2.0s以后会自动调用self的hidHUD方法
186 //        [self performSelector:@selector(hideHUD) withObject:nil afterDelay:1.5];
187 //        [self performSelector:@selector(hideHUD) withObject:nil afterDelay:1.5];
188 //        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
189 //            self.hud.alpha = 0.0;
190 //        });
191    //   [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(hideHUD) userInfo:nil repeats:NO];
192 @end

加载plist数据

  1 #import "ViewController.h"
  2
  3 @interface ViewController ()
  4 /** 存放所有商品的整体 */
  5 @property (weak, nonatomic) IBOutlet UIView *shopsView;
  18 @end
 19
 20 @implementation ViewController
 21
 22 - (void)viewDidLoad
 23 {
 24     [super viewDidLoad];
 25
 26     // 添加“添加按钮”
 27     self.addBtn = /*****/
 29     // 添加“删除按钮”
 30     self.removeBtn = /***/ 31     self.removeBtn.enabled = NO;
 32
 33     // 加载plist数据
 34
 35     // 一个NSBundle对象对应一个资源包(图片、音频、视频、plis等文件)
 36     // NSBundle的作用:用来访问与之对应的资源包内部的文件,可以用来获得文件的全路径
 37     // 项目中添加的资源都会被添加到主资源包中
 38     // [NSBundle mainBundle]关联的就是项目的主资源包
 39     NSBundle *bundle = [NSBundle mainBundle];
 40
 41     // 利用mainBundle获得plist文件在主资源包中的全路径
 42     NSString *file = [bundle pathForResource:@"shops" ofType:@"plist"];
 43 //    NSString *file = [bundle pathForResource:@"shops.plist" ofType:nil];
 44
 45     // 凡是参数名为File,传递的都是文件的全路径
 46     self.shops = [NSArray arrayWithContentsOfFile:file];
 47 }
 48
 49 #pragma mark 添加按钮
 50 - (UIButton *)addButtonWithImage:(NSString *)image highImage:(NSString *)highImage disableImage:(NSString *)disableImage                   frame:(CGRect)frame action:(SEL)action
 51 {
 52    .... 65 }
 66
 67 #pragma mark 添加
 68 - (void)add
 69 {
 70   .....122 }
123
124 #pragma mark 删除
125 - (void)remove
126 {
127     ...131 }
132
133 #pragma mark 检查状态:按钮状态
134 - (void)checkState
135 {
136    ...155 }
156
157 @end
加载plist数据(比较大)->懒加载懒加载:用到时再去加载,而且也只加载一次
 1  1 #import "ViewController.h"
 2   2
 3   3 @interface ViewController ()
 4   4     ... 18 @end
 5  19
 6  20 @implementation ViewController
 7  21
 8  22 // 加载plist数据(比较大)
 9  23 // 懒加载:用到时再去加载,而且也只加载一次
10  24 - (NSArray *)shops  //重写setter方法
11  25 {
12  26     if (_shops == nil) {
13  27         NSString *file = [[NSBundle mainBundle] pathForResource:@"shops" ofType:@"plist"];
14  28         self.shops = [NSArray arrayWithContentsOfFile:file];
15  29 //        _shops = [NSArray arrayWithContentsOfFile:file];
16  30 //        [self setShops:[NSArray arrayWithContentsOfFile:file]];
17  31     }
18  32     return _shops;
19  33 }

				
时间: 2024-08-08 19:25:13

源码-03-九宫格 封装 懒加载 plist的相关文章

【Spring源码分析】非懒加载的Bean实例化过程(下篇)

doCreateBean方法 上文[Spring源码分析]非懒加载的Bean实例化过程(上篇),分析了单例的Bean初始化流程,并跟踪代码进入了主流程,看到了Bean是如何被实例化出来的.先贴一下AbstractAutowireCapableBeanFactory的doCreateBean方法代码: 1 protected Object doCreateBean(final String beanName, final RootBeanDefinition mbd, final Object[]

spring源码阅读之Bean的加载(二)

在正式分析源码之前,先来了解一下SpringBeans里面最核心的两个类  DefaultListableBeanFactory XMLBean继承自 DefaultListableBeanFactory,而 DefaultListableBeanFactory是整个Bean加载的核心部分,是Sprin注册及加载Bean的默认实现,而对于XmlBeanFactory与 DefaultListableBeanFactory不同的地方其实就是在XmlBeanFactory中使用了自定义的XML读取器

Mybatis 源码分析--Configuration.xml配置文件加载到内存

(补充知识点: 1 byte(字节)=8 bit(位) 通常一个标准英文字母占一个字节位置,一个标准汉字占两个字节位置:字符的例子有:字母.数字系统或标点符号) 1.创建SqlSessionFactory ①Reader reader = Resources.getResourceAsReader("mybatis-config.xml");                       //获取mybatis配置文件的字符 注解:Resources类是在mybatis中定义的一个类:g

MQTT---HiveMQ源码详解(四)插件加载

实现功能 将所有放在plugins目录下的所有符合plugin编写规范的plugin jar包加载到整个guice context中 实现步骤 1.找到所有plugin目录下的所有jar包 2.分别找到jar包中META-INF/services/com.hivemq.spi.HiveMQPluginModule文件读取第三方plugin配置的HiveMQPluginModule子类全路径 3.然后依次实例化它. 类图 这次的类图比上次的相比简单多了,加载机制也跟其他的有plugin机制的加载比

【Spring】从源码分析Spring配置文件的加载

使用Spring必须在web.xml中写如下配置: <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-valu

vscode源码分析【八】加载第一个画面

第一篇: vscode源码分析[一]从源码运行vscode 第二篇:vscode源码分析[二]程序的启动逻辑,第一个窗口是如何创建的 第三篇:vscode源码分析[三]程序的启动逻辑,性能问题的追踪 第四篇:vscode源码分析[四]程序启动的逻辑,最初创建的服务 第五篇:vscode源码分析[五]事件分发机制 第六篇:vscode源码分析[六]服务实例化和单例的实现 第七篇:vscode源码分析[七]主进程启动消息通信服务 先复习一下! 在第一节中,我们提到: app.ts(src\vs\co

Dubbo源码分析系列---扩展点加载

扩展点配置: 约定: 在扩展类的jar包内,放置扩展点配置文件:META-INF/dubbo/接口全限定名,内容为:配置名=扩展实现类全限定名,多个实现类用换行符分隔.(摘自dubbo文档) 示例: 假如我现在想使用自己定义的协议Myprotocol,在resources目录下新建META-INF/dubbo/com.alibaba.dubbo.rpc.Protocol目录文件,文件内容定义: myprotocol=com.selrain.MyProtocol 实现类内容: public cla

laravel的源码解析:PHP自动加载功能原理解析

前言 这篇文章是对PHP自动加载功能的一个总结,内容涉及PHP的自动加载功能.PHP的命名空间.PHP的PSR0与PSR4标准等内容. 一.PHP自动加载功能 PHP自动加载功能的由来 在PHP开发过程中,如果希望从外部引入一个 class,通常会使用 include 和 require 方法,去把定义这个 class 的文件包含进来.这个在小规模开发的时候,没什么大问题.但在大型的开发项目中,使用这种方式会带来一些隐含的问题:如果一个 PHP 文件需要使用很多其它类,那么就需要很多的 requ

看看Spring的源码(一)——Bean加载过程

首先Web项目使用Spring是通过在web.xml里面配置org.springframework.web.context.ContextLoaderListener初始化IOC容器的. <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> 那就以此为切入点顺藤摸瓜. public class