zoukankan      html  css  js  c++  java
  • ios使用jspatch中需要注意的事项

    第一份代码,为了纠正原代码不显示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 

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

  • 相关阅读:
    海尔U+的启发:让用户对智能家居拥有“话语权”
    关于hash和ico的一些关联
    二维码简单介绍
    卡特兰数 大数模板
    C++ Linux 多线程之创建、管理线程
    Objective-c开发教程--MRC和ARC混编
    APP 打包測试流程 从零開始
    hdu4848 求到达每一个点总时间最短(sum[d[i]])。
    表结构变更后出现的ERROR OGG-01161 Bad column index (88)
    【Linux学习】Ubuntu下内核编译(一)
  • 原文地址:https://www.cnblogs.com/machao/p/5227717.html
Copyright © 2011-2022 走看看