ios使用jspatch中需要注意的事项

news/2024/7/8 2:22:07

第一份代码,为了纠正原代码不显示29号的bug,先上代码

 1 require('NSString','MCDatePickType','NSMutableArray','UIButton');
 2 
 3 defineClass('MMCDatePickView',{
 4 
 5     setDatePickViewSelected: function() {
 6 
 7     self.setSelectedYearRow(self.yearArray().indexOfObject(self.currentYearString()));
 8     self.setSelectedDayRow(self.DaysArray().indexOfObject(self.currentDayString()));
 9     self.setSelectedHourRow(self.hoursArray().indexOfObject(self.currentHourString()));
10     self.setSelectedMinuteRow(self.minutesArray().indexOfObject(NSString.stringWithFormat("%@分", self.currentMinuteString())));
11 
12 
13     // 设置年和月
14      var MonthAndYear = self.currentYearString().toJS() + '年' + self.currentMonthString().toJS() + '月';
15 
16     if (self.type() === 0) {
17 
18 
19         for (var i = 0; i < self.yearArray().count(); i++) {
20             
21             var jsArray = self.yearArray().toJS();
22             var year = jsArray[i];
23             if (year == self.currentYearString().toJS()) {
24                 
25                 self.datePickView().selectRow_inComponent_animated(i, 0, YES);
26 
27                 break;
28             }
29         }
30 
31         
32     } 
33     else {
34 
35 
36       self.setSelectedMonthRow(self.yearAndMonthArray().indexOfObject(MonthAndYear));
37       self.datePickView().selectRow_inComponent_animated(self.selectedMonthRow(), 0, YES);
38        
39 
40     if (self.type() !== 0 && self.type() !== 1 && self.type() !== 5) {
41         self.datePickView().selectRow_inComponent_animated(self.selectedDayRow(), 1, YES);
42     }
43 
44 
45     //选中小时
46     if (self.type() === 3 || self.type() === 4) {
47         self.datePickView().selectRow_inComponent_animated(self.selectedHourRow(), 2, YES);
48     }
49 
50     //选中分
51     if (self.type() === 4) {
52         self.datePickView().selectRow_inComponent_animated(self.selectedMinuteRow(), 3, YES);
53     }
54 
55 
56     // 选中自定义的
57     if (self.type() === 5) {
58         self.datePickView().selectRow_inComponent_animated(self.customerIndex(), 0, YES);
59     }
60 }
61 }
62 });

 

注意事项:

1.在对字符或者数组,字典操作的时候应该转成js的字符串或者字典,等等

 1 var MonthAndYear = self.currentYearString().toJS() + '年' + self.currentMonthString().toJS() + '月'; 

上边的代码是正确的,MonthAndYear 就是js格式的字符串,下边的是不对的:

var MonthAndYear = self.currentYearString() + '年' + self.currentMonthString() + '月';

2.在进行比较的时候,使用相同类型,js的数据类型和oc的不一样

1 var jsArray = self.yearArray().toJS();
2             var year = jsArray[i];
3             if (year == self.currentYearString().toJS()) {
4                 
5                 self.datePickView().selectRow_inComponent_animated(i, 0, YES);
6 
7                 break;
8             }

3.js 是弱类型语言,不强调类型,oc的枚举在js中不好使,

 1 self.type() === 0 

最终还是把枚举转成了基本数据类型

 


http://www.niftyadmin.cn/n/4255944.html

相关文章

【linux】tree显示目录结构

安装&#xff1a; sudo apt-get install tree

【python】自动化测试框架--nose

目录一、准备二、nose介绍三、看个简单的例子了解下三、nose常用命令简单介绍1、查看所有nose相关命令2、 执行并捕获输出3、 提供XUnit XML 格式的测试结果&#xff0c;并存储在nosetests.xml文件中。主要为jenkins等能理解xnuit格式文件的集成测试环境准备。4、 查看nose的运…

audacity开源VS2013环境搭建

audacity是非常不错的音频开源&#xff0c;其中音频效果处理的种类很多&#xff0c;非常方便借鉴和研究。 但是audacity的界面库是使用wxWidgets(一个跨平台的界面库)&#xff0c;配置过程中需要折腾一下。 1&#xff0c;首先去下载一下wxWidgets库 下载地址&#xff1a;https:…

solarwinds 9.1 升级到9.5注意事项

1、如果以前用的是SQL2000,则先安装SQL2005&#xff0c;和SQL2000可以并存的2、将SQL2000数据库复原到SQL2005里3、通过管理配置向导将NPM NCM APM 等数据库源地址设置到SQL2005里4、升级APM到2.5以上版本5、升级NCM到5.5版本&#xff08;NPM-Integration服务需要先删除掉&…

HttpApplication 类,HttpApplicationState 类

HttpApplication 类 定义 ASP.NET 应用程序中的所有应用程序对象共有的方法、属性和事件。此类是用户在 Global.asax 文件中所定义的应用程序的基类。 https://msdn.microsoft.com/zh-cn/library/system.web.httpapplication(vvs.110).aspx HttpApplicationState 类 启用 ASP.N…

【框架】Jenkins学习总结--安装

目录一、准备二、介绍&#xff1a;构建伟大&#xff0c;无所不能三、优势&#xff1a;四、jenkins下载、安装一、准备 第一次使用 Jenkins&#xff0c;您需要&#xff1a; 机器要求&#xff1a; 256 MB 内存&#xff0c;建议大于 512 MB 10 GB 的硬盘空间&#xff08;用于 Jen…

Jenkins报错解决:There were errors checking the update sites: SSLHandshakeException: sun.security.valid

报错如下&#xff1a; There were errors checking the update sites: SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification p…

测试hadoop集群是否安装成功:网页监控页面和提交job运行

为什么80%的码农都做不了架构师&#xff1f;>>> 一、查看集群的网页监控状态 1.查看hdfs集群状态&#xff0c;也就是namenode的访问地址 配置&#xff1a;hdfs-site.xml--dfs.namenode.http-address 默认访问地址&#xff1a;http://namenode的ip:50070 2.如果配置…