首页 文章 精选 留言 我的

精选列表

搜索[渲染问题],共10000篇文章
优秀的个人博客,低调大师

js之Date()方法获取时间问题

最近做的秒杀页面通过js切换时候发现ios上无效,在电脑模拟手机环境上正常。 最后发现: new Date('xxxx/xx/xx xx:xx:xx') 形式的时间对象在 IOS 和 Andriod 系统上都可以被正确的识别,而类似 new Date('xxxx-xx-xx xx:xx:xx') 形式的时间对象在 ios 系统上无法被正确的识别,需要做一层转化。 本文转自 水滴的历程 51CTO博客,原文链接:http://blog.51cto.com/12390959/2047427

优秀的个人博客,低调大师

IIS不支持apk文件下载问题

默认情况,通过http或https无法直接下载apk的链接文件,提示无法找到此文件或路径错误,这是因为在IIS的默认MIME类型中没有.apk文件,不支持APK文件下载。 解决办法:在IIS的MIME类型中添加apk类型即可。 IIS服务器不能下载.apk文件的解决步骤: 打开IIS服务管理器,找到MIME类型; 双击打开,在空白处右键选择“添加”,建立新的MIME类型; 扩展名中填写“.apk”, MIME类型中填写apk的MIME类型“application/vnd.android.package-archive” 单击“确定”保存设置。 重启IIS,使设置生效。 使用IIS服务器的网站就可以下载.apk文件了。 本文转自 lorysun 51CTO博客,原文链接:http://blog.51cto.com/lorysun/1333339

优秀的个人博客,低调大师

Swift 中 String 取下标及性能问题

取下标 String String 用 String.Index 取下标(subscript)得到 Character,String.Index 要从 String 中获取 letgreeting="GutenTag!"greeting[greeting.startIndex]//Character"G"greeting[greeting.index(before:greeting.endIndex)]//Character"!"greeting[greeting.index(after:greeting.startIndex)]//Character"u"letindex=greeting.index(greeting.startIndex,offsetBy:7) greeting[index]//Character"a" String 用 Range<String.Index> 或 ClosedRange<String.Index> (以下 Range 和 ClosedRange 统称为 Range) 取下标得到 String letstr="abc"str[str.startIndex..<str.index(after:str.startIndex)]//String"a"str[str.startIndex...str.index(after:str.startIndex)]//String"ab" Character String 通过 characters 属性获得 String.CharacterView,表示屏幕上显示的内容。String.CharacterView 通过 String.CharacterView.Index 取下标得到 Character,String.CharacterView.Index 要从 String.CharacterView 中获取 letstr="abc"letcharacters=str.characters//String.CharacterViewcharacters[characters.startIndex]//Character"a" 注意,String.CharacterView 不遵循 RandomAccessCollection 协议,用 String.CharacterView.Index 取下标不可以随机访问。另外,String.CharacterView.Index 与 String.Index 是相同的类型,属于 Struct。String.Index 的文档在 String 文档下 typealiasIndex=String.CharacterView.Index String.CharacterView 通过 Range<String.CharacterView.Index> 得到 String.CharacterView。用 Character 和 String.CharacterView 都可以生成 String letstr="abc"letcharacters=str.characters//String.CharacterViewletcharacters2=characters[characters.startIndex..<characters.index(after:characters.startIndex)]//String.CharacterViewString(characters.first!)==String(characters2)//true.characters.first!isCharacter 用 String.CharacterView 生成 Array<Character>,可以用 Int、Range<Int> 取下标。用 Array<Character> 也可以生成 String letstr="abc"letarr=Array(str.characters)//Array<Character>["a","b","c"]arr[1]//Character"b"arr[1...2]//ArraySlice<Character>["b","c"]String(arr)//String"abc" Character 可以直接与 "a" 比较 letstr="abc"leta=str[str.startIndex]//Character"a"letb=str[str.index(str.startIndex,offsetBy:1)]//Character"b"a=="a"//trueb>"a"//true UTF-8 String 通过 utf8 属性获得 String.UTF8View,表示 UTF-8 编码的内容。String.UTF8View 通过 String.UTF8View.Index 取下标得到 UTF8.CodeUnit,实际上是 UInt8;通过 Range<String.UTF8View.Index> 取下标得到 String.UTF8View。String.UTF8View.Index 要从 String.UTF8View 中获取。String.UTF8View 不遵循 RandomAccessCollection 协议,用 String.UTF8View.Index 取下标不可以随机访问。用 String.UTF8View 生成 Array<UInt8>,可以用 Int、Range<Int> 取下标。用 String.UTF8View 可以生成 String。用 UInt8 或 Array<UInt8> 也可以生成 String,但内容表示数字或数字数组,不是数字的 UTF-8 编码内容。 letstr="abc"letutf8=str.utf8//String.UTF8Viewletn=utf8[utf8.startIndex]//UInt897leta=utf8[utf8.startIndex..<utf8.index(after:utf8.startIndex)]//String.UTF8View"a"letab=utf8[utf8.startIndex...utf8.index(after:utf8.startIndex)]//String.UTF8View"ab"String(n)//"97",NOT"a"String(a)//"a"String(ab)//"ab"letarr=Array(utf8)//Array<UInt8>[97,98,99]letn2=arr[0]//UInt897letarr2=arr[0...1]////ArraySlice<UInt8>[97,98] String 通过 utf8CString 属性获得 ContiguousArray<CChar>,实际上是 ContiguousArray<Int8>,表示 UTF-8 编码的内容并且末尾增加一个 0,所以长度比 utf8 属性的长度大 1。ContiguousArray<Int8> 可以用 Int、Range<Int> 取下标,分别得到 Int8 和 ArraySlice<Int8>。ContiguousArray 遵循 RandomAccessCollection 协议,用 Int 取下标可以随机访问。 letstr="abc"letutf8=str.utf8CString//ContiguousArray<Int8>[97,98,99,0]leta=utf8[0]//Int897letab=utf8[0...1]//ArraySlice<Int8>[97,98] UTF-16 String 通过 utf16 属性获得 String.UTF16View,表示 UTF-16 编码的内容。String.UTF16View 通过 String.UTF16View.Index 取下标得到 UTF16.CodeUnit,实际上是 UInt16;通过 Range<String.UTF16View.Index> 取下标得到 String.UTF16View。String.UTF16View.Index 要从 String.UTF16View 中获取。String.UTF16View 遵循 RandomAccessCollection 协议,用 String.UTF16View.Index 取下标可以随机访问。用 String.UTF16View 生成 Array<UInt16>,可以用 Int、Range<Int> 取下标。用 String.UTF16View 可以生成 String。用 UInt16 或 Array<UInt16> 也可以生成 String,但内容表示数字或数字数组,不是数字的 UTF-16 编码内容。 letstr="abc"letutf16=str.utf16//String.UTF16Viewletn=utf16[utf16.startIndex]//UInt1697leta=utf16[utf16.startIndex..<utf16.index(after:utf16.startIndex)]//String.UTF16View"a"letab=utf16[utf16.startIndex...utf16.index(after:utf16.startIndex)]//String.UTF16View"ab"String(n)//"97",NOT"a"String(a)//"a"String(ab)//"ab"letarr=Array(utf16)//Array<UInt16>[97,98,99]letn2=arr[0]//UInt1697letarr2=arr[0...1]////ArraySlice<UInt8>[97,98] 性能对比 对 String、String.CharacterView、Array<Character>、String.UTF8View、Array<UInt8>、ContiguousArray<Int8>、String.UTF16View、Array<UInt16> 进行判空(isEmpty)、获取长度(count)、一个位置的取下标([index])、一段距离的取下标([range])测试,统计执行时间。 定义测试类型、打印和更新时间的方法、要测试的 String importFoundationenumTestType{caseisEmptycasecount caseindexcaserange }funcprintAndUpdateTime(_date:inoutDate){letnow=Date()print(now.timeIntervalSince(date)) date=now }lets="aasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafcpiluioufnlkqjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjliopjktyuljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasderwytwghfsdfsdfgfdsgvrutj7edbj7fdgotuyoergcwhmkl5lknjklqawkyrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcvcnvbwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjknfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgiopiouvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkfghngdljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmbkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqasdfsdwkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljdqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasddfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbsdfdsrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfsadfsdgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqsdfasjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdafgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlkasdfsdfsdfgfdsgvrutj7edbj7ergcwhmkl5lknjklqawkrcqjljkljqjlqjhbrlqwfcbhafciluioufnlkjvjakjnfnvjalgkhlkdkjlk" 测试代码 letloopCount=10000letindex=s.characters.count/2lettestType:TestType=.rangeprint(testType)vardate=Date() forLoop:for_in0..<loopCount{switchtestType{case.isEmpty:_=s.isEmptycase.count:breakforLoopcase.index:_=s[s.index(s.startIndex,offsetBy:index)]case.range:letendIndex=s.index(s.startIndex,offsetBy:index)_=s[s.startIndex..<endIndex] } }iftestType==.count{ date=Date() }else{print("String") printAndUpdateTime(&date) }letcharacters=s.charactersfor_in0..<loopCount{switchtestType{case.isEmpty:_=characters.isEmptycase.count:_=characters.count case.index:_=characters[characters.index(characters.startIndex,offsetBy:index)]case.range:letendIndex=characters.index(characters.startIndex,offsetBy:index)_=characters[characters.startIndex..<endIndex] } }print("Characters") printAndUpdateTime(&date)letcharacterArr=Array(characters)for_in0..<loopCount{switchtestType{case.isEmpty:_=characterArr.isEmptycase.count:_=characterArr.count case.index:_=characterArr[index]case.range:_=characterArr[0..<index] } }print("Charactersarray") printAndUpdateTime(&date)letutf8=s.utf8for_in0..<loopCount{switchtestType{case.isEmpty:_=utf8.isEmptycase.count:_=utf8.count case.index:_=utf8[utf8.index(utf8.startIndex,offsetBy:index)]case.range:letendIndex=utf8.index(utf8.startIndex,offsetBy:index)_=utf8[utf8.startIndex..<endIndex] } }print("UTF-8") printAndUpdateTime(&date)letutf8Arr=Array(utf8)for_in0..<loopCount{switchtestType{case.isEmpty:_=utf8Arr.isEmptycase.count:_=utf8Arr.count case.index:_=utf8Arr[index]case.range:_=utf8Arr[0..<index] } }print("UTF-8array") printAndUpdateTime(&date)letutf8CString=s.utf8CStringfor_in0..<loopCount{switchtestType{case.isEmpty:_=utf8CString.isEmptycase.count:_=utf8CString.count case.index:_=utf8CString[index]case.range:_=utf8CString[0..<index] } }print("UTF-8Cstring") printAndUpdateTime(&date)letutf16=s.utf16for_in0..<loopCount{switchtestType{case.isEmpty:_=utf16.isEmptycase.count:_=utf16.count case.index:_=utf16[utf16.index(utf16.startIndex,offsetBy:index)]case.range:letendIndex=utf16.index(utf16.startIndex,offsetBy:index)_=utf16[utf16.startIndex..<endIndex] } }print("UTF-16") printAndUpdateTime(&date)letutf16Arr=Array(utf16)for_in0..<loopCount{switchtestType{case.isEmpty:_=utf16Arr.isEmptycase.count:_=utf16Arr.count case.index:_=utf16Arr[index]case.range:_=utf16Arr[0..<index] } }print("UTF-16array") printAndUpdateTime(&date) 测试结果 判空 获取长度 一个位置的取下标 一段距离的取下标 以上比较中,判断 String 是否为空,访问 String 的 isEmpty 速度最快。对于其他操作,遵循 RandomAccessCollection 协议(ContiguousArray<Int8>、String.UTF16View 以及其他 Array)的类型效率较高。 进一步比较判空操作 letloopCount=10000vardate=Date()for_in0..<loopCount{_=s.isEmpty }print("isEmpty") printAndUpdateTime(&date)for_in0..<loopCount{_=s==""}print("==\"\"") printAndUpdateTime(&date) 与访问 String 的 isEmpty 相比,判断 String 是否等于空 String 速度更快! 注意到文档中,对 String.UTF8View 和 String.UTF16View 的 Range 取下标方法的说明 subscript(bounds:Range<String.UTF8View.Index>)->String.UTF8View{get}subscript(bounds:Range<String.UTF16View.Index>)->String.UTF16View{get} Complexity:O(n)iftheunderlyingstringisbridgedfromObjective-C,wherenisthelengthofthestring;otherwise,O(1). 如果 String 是从 Objective-C 的 NSString 桥接来的,时间复杂度为 O(n),否则为 O(1)。这句话怎么理解呢?前面说了,String.UTF8View 不遵循 RandomAccessCollection 协议,而 String.UTF16View 遵循 RandomAccessCollection 协议,两者的时间复杂度应该不同。这里怎么说时间复杂度与 String 是否桥接自 NSString 有关?以下进一步探究。 lets2=NSString(string:s)asStringletloopCount=10000letindex=s.characters.count/2letindex2=s.characters.count-1functest(_s:String){vardate=Date() letutf8=s.utf8for_in0..<loopCount{_=utf8[utf8.startIndex..<utf8.index(utf8.startIndex,offsetBy:index)] } print("UTF-8index") printAndUpdateTime(&date) for_in0..<loopCount{_=utf8[utf8.startIndex..<utf8.index(utf8.startIndex,offsetBy:index2)] } print("UTF-8index2") printAndUpdateTime(&date) letutf16=s.utf16for_in0..<loopCount{_=utf16[utf16.startIndex..<utf16.index(utf16.startIndex,offsetBy:index)] } print("UTF-16index") printAndUpdateTime(&date) for_in0..<loopCount{_=utf16[utf16.startIndex..<utf16.index(utf16.startIndex,offsetBy:index2)] } print("UTF-16index2") printAndUpdateTime(&date) }print("String") test(s)print("\nStringbridgedfromNSString") test(s2) 测试结果 对比 index 与 index2 的差异。测试参数 index2 约为 index 的 2 倍。UTF-8 index2 的耗时也约为 index 的 2 倍。UTF-16 的 index 和 index2 耗时相近。这与是否遵循 RandomAccessCollection 协议一致。 对比 String 与 NSString 的差异。桥接自 NSString 的 String 耗时比 String 要长,UTF-8 尤其明显。这应该就是文档说明的情况。用 Range 取下标,桥接自 NSString 的 String,比 String 多一些操作,多出 O(n) 级别的时间,而不是取下标的时间复杂度是 O(n)。 应用 具体应用时,选取哪种编码方式、取下标方式?首先,编码方式要看具体应用场景。编码方法不同,字符串的长度可能不同。如果字符串只含英文,比较好办。如果字符串含有中文或 Emoji,选择编码方式就要慎重。注意,NSString 的 length 属性获得的长度对应 UTF-16 编码。 letstr="abc"str.characters.count//3str.unicodeScalars.count//3str.utf16.count//3(strasNSString).length//3str.utf8.count//3str.utf8CString.count-1//3strlen(str)//3letemojiStr=""emojiStr.characters.count//1emojiStr.unicodeScalars.count//2emojiStr.utf16.count//4(emojiStrasNSString).length//4emojiStr.utf8.count//8emojiStr.utf8CString.count-1//8strlen(emojiStr)//8letChineseStr="中文"ChineseStr.characters.count//2ChineseStr.unicodeScalars.count//2ChineseStr.utf16.count//2(ChineseStrasNSString).length//2ChineseStr.utf8.count//6ChineseStr.utf8CString.count-1//6strlen(ChineseStr)//6 本文转自xmgdc51CTO博客,原文链接:http://blog.51cto.com/12953214/1940545 ,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS10 ATS / 非HTTPS被禁问题

iOS9 中默认非HTTPS的协议是被禁止的,解决方案是我们可以在info.plist文件中添加AppTransportSecuritySettings字典,将NSAllowsArbitraryLoads设置为YES来禁用ATS。 iOS10从2017年1月1日起苹果提出所有新提交的App默认不允许使用NSAllowsArbitraryLoads来绕过ATS的限制,也就是说强制我们用HTTPS,如果不这样的话提交App可能会被拒绝。 解决方案:我们可以通过NSExceptionDomains设置白名单的方式来针对特定的域名开放HTTP内容来通过审核。可以简单理解成,把不支持https协议的接口设置成http的接口。 操作: 1)在项目info.plist中添加一个Key:App Transport Security Settings,类型为 Dictionary; 2)在其内添加一个Key: Exception Domains,类型为Dictionary; 3)在Exception Domains内添加要支持的域,其中域作为Key,类型为Dictionary; 4)每个域下面需要设置3个属性:类型为Boolean; NSIncludesSubdomains YES NSExceptionRequiresForwardSecrecy NO NSExceptionAllowsInsecureHTTPLoads YES 注意:每个需添加的域都需要设置此三个属性。如果请求的网络图片是HTTP,也是需要设置的图片的域。 本文转自ljianbing51CTO博客,原文链接:http://blog.51cto.com/ljianbing/1876018,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android 解决Activity切换时出现白屏问题

解决办法 在style.xml文件中的全局主题下添加 <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> 添加之后的主题样式如下: <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> </style>

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册