动态 iOS 版升级记录

1。关于五笔画模式下,不能模糊匹配折笔的Bug

	func getSqliteStroke(stroke:String,
					  _bcmptb:Bool,
					  _bregexp:Bool)->String{
		var valquery = stroke
		var columidx = 3
		if(_bregexp){
			columidx = 4
		}
		
        // 2020-04-04 似乎这里是造成 5笔画模式无法适配 车 牛 等正则匹配的原因。
		/*if(_bcmptb){ // 乛 丨亅
			for idx in 0..<2 {
				if stroke == alterstr[idx][2] {
					valquery = alterstr[idx][columidx]
				}
			}
		}else{
			var binalterstr = false
			var idx = 2
			while !binalterstr && idx < alterstr.count{
				if stroke == alterstr[idx][2] {
					valquery = alterstr[idx][columidx]
					binalterstr = true
				}else{
					idx += 1
				}
			}
		}*/
        
        var binalterstr = false
        var idx = 0  // 乛 || 亅
        if(!_bcmptb){
            idx = 2
        }
        while !binalterstr && idx < alterstr.count{
            if stroke == alterstr[idx][2] {
                valquery = alterstr[idx][columidx]
                binalterstr = true
            }else{
                idx += 1
            }
        }
		
		Swift.print(stroke+",_bregexp:\(_bregexp),"+"_bcmptb:\(_bcmptb),"+valquery+",alterstr.count:\(alterstr.count)")
		return valquery
	}
}

2。按键颜色是在哪里定义的?

func createButtonWithTitles

定义了:color_white,然后赋值 green,在很多UI都生效了,就是 darkmode 不变 blue

设置:settings -> developer -> darkapparence  生效了。

在 getUserDefalut() 里:

        if #available(iOS 13, *) {
            color_white = UIColor { (trait) -> UIColor in
                if trait.userInterfaceStyle == .light{
                    return UIColor.green
                } else {
                    return UIColor.blue
                }
            }
        }

工具栏的左右移动按钮为什么不变色?是为了显示按下效果,用图片做了背景

 

    func createToolbar(){
        var toolbtn=[UIButton]()
        let tooltitle = ["🌐","↤","↦","^-^","☺︎","@#\n&%","💬","🛠","⚙️"]//☼🌩☁🙂📃@#❜⚒🔣
        for i in 0 ..< tooltitle.count {
            toolbtn.append(createButtonWithTitle_toolbar(title: tooltitle[i]))
        }
        
        //toolbtn[0].setBackgroundImage(Icon_Mac, for: .normal)
        //toolbtn[0].titleLabel?.font = UIFont.systemFont(ofSize: CGFloat(fontSize_subKey))
        
        toolbtn[1].setBackgroundImage(bg1, for: .normal)
        toolbtn[1].setBackgroundImage(bg4, for: .highlighted)
        toolbtn[2].setBackgroundImage(bg1, for: .normal)
        toolbtn[2].setBackgroundImage(bg4, for: .highlighted)

///
}

而初始化背景的代码用到了 color_white,所以应该在 getUserDefalut() 之后执行。

 

如何优雅地解决颜色的问题:

        let colorKeys = colorMap.allKeys
        
        if #available(iOS 13, *) {
            
            for key in colorKeys {
                let newcolor = UIColor{ (trait) -> UIColor in
                    if trait.userInterfaceStyle == .light{
                        return self.colorMap0.value(forKey:key as! String) as! UIColor//UIColor.green
                    } else {
                        return self.colorMap1.value(forKey:key as! String) as! UIColor//UIColor.blue
                    }
                }
                colorMap.setValue(newcolor,forKey:key as! String)
            }
            
            placeColor()
        }

 

4值按键的颜色设置很乱,统一改为:btn.setSubLablesColor(C123: color_darkGray,C4: color_darkGray)

                            light                 dark

     color_white                1.0                   0.2

     color_veryLightGray        0.7                   0.3

     color_lightGray            dark                  light

     color_gray                 gray                  gray

     color_darkGray             light                 dark

     color_black                0.0                   0.8

 

 

     color_half                 a=0.66                a=0.66

     color_shadow               135,139,143           28,28,28

     color_bg                   210,213,219           43,43,43

     color_funbtn               178,189,199           70,70,70

     color_touch                148,159,169           213,213,213

 

     

3。键盘弹出状态不对的问题:

不能记忆键盘状态,不能设字号。经查,是 LoadView 中,

        initFontSize(bLarge: blargelabel)

        kbdState = KeyboardState.init(kbdName: curKbdName,lastCnKbdName : lastCnKbdName,bland: bland)

跑到了          getUserDefaults()   的前面。

 

4。单笔画不在候选列表的问题

早期版本,是按笔画查出候选字后,先按匹配度排序,再按字频排序,笔画不丢失。

上一版本,是直接用 sql 语句查询并按字频排序,导致单笔画丢失。使用的是 glob XXX*  语句。

权宜之计:利用 sql 语句将 单笔画的字频设为某一大数(大于「的」)

	func startdb(){
		// 清理3.2以前的数据库。
		let docDir = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)[0]
		let path = (docDir as NSString).appendingPathComponent("data.db")
		//NSLog("Database path: \(path)")
		let fileManager = FileManager.default
		do{
			try fileManager.removeItem(atPath: path)
		}catch{
			//print("file had been removed .")
		}
		
		db = SQLiteDB.shared//.sharedInstance// 此后,应在键盘里设置初始化参数。
        
        db.execute(sql: "UPDATE chara_csrftn_table set frq = 0.05 where chara=='丨';") // frq_max = 0.039 的
        db.execute(sql: "UPDATE chara_csrftn_table set frq = 0.05 where chara=='丿';") // frq_max = 0.039 的
        db.execute(sql: "UPDATE chara_csrftn_table set frq = 0.05 where chara=='丶';") // frq_max = 0.039 的

		sqlui.startdb(_db: db)
		sqlui.encodeRadical()
	}

5。从 iCloud 恢复设置崩溃的问题

竟然是拼写错误造成!真机调试才发现!

icloud.set(self.shared?.value(forKey: "sysmkbd"),forKey: "symskbd")

self.shared?.set(icloud.string(forKey: "sysmkbd"),forKey:"symkbd")

 

6。本次升级异常惨烈,竟然把主用的 iPhone6SP 变砖了!

从11.x 直升13.7,就为了有暗黑模式,结果悲剧了,除了通信录,全丢!

后记:升级前自动备份了,基本都恢复了。

 

7。关于 UITableView 暗黑模式下上下留白边的问题,经过长期摸索,是这个原因:

选中 UITableView,在属性的 ScorllView 背景色那里,设置 clear双色,而不是 default (有的页面是双色,更多的是白色单色)。default 不同,这就是看起来属性参数完全一样,但就是有的页面有白边,有的没有的原因。

 

8。更正五笔画模式下快捷键功能错误:

			// 20151025 addtion
			var qchara = ""
			// 快捷键 、、
            //if(_mComposing2 == "44" && keyrecorder.segs_key[keyrecorder.segidx_curseg][0] != "⺀"){// 先判断是否键入了 、、,如果是,qchara为last
            if(_mComposing2 == "44" && keyrecorder.segs_key[0][0] != "⺀"){// 先判断是否键入了 、、,如果是,qchara为last
                    let charbefore = _docB4Input
				let charlength = charbefore.count
				// 此处在MacOS版本调试时更改 20170211
				//let flrlength = flr.count
				if(_segidx==0){
					qchara = substring(charbefore,idx1:charlength-1,idx2:charlength)
				}
				//print(qchara)
			}else{// 如果否,就看是否键入了快捷键,如果是,qchara为快捷键
				for i in 0 ..< quickstr.count {
					//let str=(_bxstro && !_blimited) ? quickstr[i][1] : quickstr[i][2] // 2020-09-06 之前的问题代码
                    let str = bcmptb ? quickstr[i][2] : quickstr[i][1] // 2020-09-06 是否兼容笔画?是,选列2
                    if(str == _mComposing2){
						qchara = quickstr[i][0]
					}
                    Swift.print("mComposing2 = "+_mComposing2+",str = "+str+", quickstr[i] = "+quickstr[i][0]+","+quickstr[i][1]+","+quickstr[i][2]+",")
				}
			}

9。配色错乱的问题:

(1)cand条,row0.backgroundColorrow0[i] button 的背景图,不正常。

(2)toolbar条,toolbar.backgroundColor、toolbar[i] button 的背景色,正常,唯有左右光标键的背景图不正常。

row0.backgroundColor 在 loadView() 的 initCand() 中初始化。并在 viewWillAppear 中重复设置。

toolbar.backgroundColor 也在 loadView() 的 initCand() 后一句的createToolbar()初始化。并在 viewWillAppear 中重复设置。

 

 

   func createToolbarHandle(){
        toolbarHandle = UIButton(frame: CGRectMake(0,0,CGFloat(height_candBar)*toolbarHandleWidth,CGFloat(height_candBar)))
        toolbarHandle.translatesAutoresizingMaskIntoConstraints = false
        toolbarHandle.setTitle("<", for: .normal)
        toolbarHandle.backgroundColor = color_white
        toolbarHandle.setTitleColor(color_darkGray,for: .normal)
        toolbarHandle.titleLabel?.font = UIFont.systemFont(ofSize: CGFloat(fontSize_mainKey_large))
        toolbarHandle.addTarget(self, action: #selector(didTapButton_toolbarHandle), for: .touchUpInside)
        toolbarHandle.addTarget(self, action: #selector(didTapButton_toolbarHandle), for: .touchDragEnter)
        
        self.view.addSubview(toolbarHandle)

 

        row0 = createRowOfButtons_cand(buttons: btn)
        row0.translatesAutoresizingMaskIntoConstraints = false
        addIndividualButtonConstraints_cand(buttons:  btn, mainView: row0)
        row0.backgroundColor = color_white
        
        row0.removeConstraints(row0.constraints)
        addIndividualButtonConstraints_cand(buttons:  btn , mainView: row0)
        row0.contentSize = CGSize(width: totallen*CGFloat(1.2),height: 0)
        
        self.view.addSubview(row0)
        docCandbar()
        toolbar = createRowOfButtons_cand(buttons: toolbtn)
        toolbar.contentSize = CGSize(width: Int((Double(fontSize_cand)+Double(kEnlarge_cand)+Double(kGap_cand))*Double(10)),height: 0)
        
        toolbar.translatesAutoresizingMaskIntoConstraints = false
        addIndividualButtonConstraints_toolbar(buttons:  toolbtn, mainView: toolbar)
        toolbar.backgroundColor = color_white
        self.view.addSubview(toolbar)

 

10。又发现初始候选字点击崩溃的问题,原因:没有给 dTyper.listSurg 初始化。

11。又发现:按键提示不能关闭,原因:shared1.set(bPreview,forKey: "bshown_pre")  应为:shared1.set(bPreview,forKey: "bPreview")。

 

========

1。增加深色模式;

2。解决键盘弹出状态不对的问题:按键提示不能关闭,不能记忆键盘状态,不能设字号;

3。解决单笔画不在候选列表的问题;

4。解决从 iCloud 恢复设置崩溃的问题;

5。解决五笔画模式下快捷键功能错误;

6。解决初始候选字点击崩溃的问题;

7。解决五笔画模式下,不能模糊匹配折笔的问题;

8。隐藏九宫格部首后仍可滑动输入部首;

9。九宫格标点"@"和"「」"互换,以避免在微信中误按"@"造成跳转。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值