首页 技术 正文
技术 2022年11月12日
0 收藏 944 点赞 4,560 浏览 1999 个字

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

 require('NSString','MCDatePickType','NSMutableArray','UIButton'); defineClass('MMCDatePickView',{     setDatePickViewSelected: function() {     self.setSelectedYearRow(self.yearArray().indexOfObject(self.currentYearString()));
self.setSelectedDayRow(self.DaysArray().indexOfObject(self.currentDayString()));
self.setSelectedHourRow(self.hoursArray().indexOfObject(self.currentHourString()));
self.setSelectedMinuteRow(self.minutesArray().indexOfObject(NSString.stringWithFormat("%@分", self.currentMinuteString()))); // 设置年和月
var MonthAndYear = self.currentYearString().toJS() + '年' + self.currentMonthString().toJS() + '月'; if (self.type() === 0) { for (var i = 0; i < self.yearArray().count(); i++) { var jsArray = self.yearArray().toJS();
var year = jsArray[i];
if (year == self.currentYearString().toJS()) { self.datePickView().selectRow_inComponent_animated(i, 0, YES); break;
}
} }
else { self.setSelectedMonthRow(self.yearAndMonthArray().indexOfObject(MonthAndYear));
self.datePickView().selectRow_inComponent_animated(self.selectedMonthRow(), 0, YES); if (self.type() !== 0 && self.type() !== 1 && self.type() !== 5) {
self.datePickView().selectRow_inComponent_animated(self.selectedDayRow(), 1, YES);
} //选中小时
if (self.type() === 3 || self.type() === 4) {
self.datePickView().selectRow_inComponent_animated(self.selectedHourRow(), 2, YES);
} //选中分
if (self.type() === 4) {
self.datePickView().selectRow_inComponent_animated(self.selectedMinuteRow(), 3, YES);
} // 选中自定义的
if (self.type() === 5) {
self.datePickView().selectRow_inComponent_animated(self.customerIndex(), 0, YES);
}
}
}
});

注意事项:

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

var MonthAndYear = self.currentYearString().toJS() + ‘年’ + self.currentMonthString().toJS() + ‘月’;

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

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

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

 var jsArray = self.yearArray().toJS();
var year = jsArray[i];
if (year == self.currentYearString().toJS()) { self.datePickView().selectRow_inComponent_animated(i, 0, YES); break;
}

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

self.type() === 0

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

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,942
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,466
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,281
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,095
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,728
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,765