
swift
文章平均质量分 53
WMSmile
这个作者很懒,什么都没留下…
展开
-
Swift 5 数组如何获取集合的索引和对应的元素值
值得注意的是,使用enumerated()方法获得的索引默认从0开始。如果你想从一个非零索引开始,可以通过传递一个参数到enumerated()方法中来指定起始索引。在Swift 5中,你可以使用enumerated()方法来获取集合的索引和对应的元素值。在上述示例中,我们使用了enumerated()方法来遍历数组array的每个元素。在这个示例中,我们使用了enumerated(startingFrom: 1)来指定索引从1开始。这样,输出的索引值会从1开始递增。原创 2023-08-10 11:23:20 · 2013 阅读 · 0 评论 -
【Cocoapods】遇到 undefined method `targets‘ for nil:nilclass 的问题
就会出现undefined methodtargets’ for nil:NilClass`的提示,提示:targets找不到了。看到这个警告一般会在Podfile的最底部添加以下代码:会报错。但是在新版本cocoapods中使用了新特性。老项目删除pods文件夹,执行。原创 2023-04-23 15:28:25 · 2562 阅读 · 1 评论 -
Swift下如何使用#if条件编译
# Swift下如何使用#if条件编译> Swift 不像ObjectC一样,通过定义一个变量,然后使用**#if #endif** 方法。OC代码如下:```objectivec#define USE_IMSDK使用#if USE_IMSDK//其他代码#endif```## Swift如果想和OC一样使用,需要设置一下才能使用。1、点击项目**targets**,点击**build setting**,搜索 **Swift Compiler Custom Flags**设原创 2023-02-16 11:33:07 · 856 阅读 · 0 评论 -
iOS上架审核之IDFA以及审核被拒问题
# iOS上架审核之IDFA以及审核被拒问题We're looking forward to completing our review, but we need more information to continue. Your app uses the AppTrackingTransparency framework, but we are still unable to locate the App Tracking Transparency permission request when原创 2022-12-08 10:52:47 · 3470 阅读 · 0 评论 -
iOS获取设备唯一标识和UUID方案
# iOS获取设备唯一标识和UUID方案以下获取**uuidString**的方法,每次重启都会改变。```swiftUIDevice.current.identifierForVendor?.uuidString``` 但是项目的要求是不变,并且删除app 只有也有有保留的需求。显然这个无法满足我们的需求。## 使用KeyChain解决> 来了解一下一KeyChain。keychain(钥匙串)存储在iOS系统中,并且恢复iPhone会使keychain的内容也恢复.但是删除App是原创 2022-03-10 18:10:44 · 1535 阅读 · 0 评论 -
【iOS开发】dyld: Symbol not found: ___chkstk_darwin 问题解决
【iOS开发】dyld: Symbol not found: ___chkstk_darwin 问题解决Xcode 13.2.1 运行到iOS12.x版本上崩溃报错如下:dyld: Symbol not found: ___chkstk_darwindyld: Symbol not found: ___chkstk_darwin Referenced from: /private/var/containers/Bundle/Application/A424CEFD-51DB-450E-9D62-B8原创 2022-03-01 18:09:57 · 6139 阅读 · 2 评论 -
【iOS开发】CMSampleBuffer 和 UIImage 相互转换
iOS CMSampleBuffer 转换 UIImageCMSampleBuffer 转换 UIImage第一种方法: /// Convert CMSampleBuffer to UIImage func WM_FUNC_sampleBufferToImage(_ sampleBuffer:CMSampleBuffer) -> UIImage { let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffe原创 2022-02-22 18:05:39 · 3035 阅读 · 0 评论 -
SwiftUI界面显示预览窗口的两种方式
# SwiftUI界面显示预览窗口的两种方式## 1.在“project”导航器中,随便选择一个使用SwiftUI的文件,然后选择“Editor”>“Canvas”。原创 2022-01-17 18:13:42 · 5878 阅读 · 0 评论 -
mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?
修复 mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?出现问题 not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?no原创 2022-01-15 22:04:36 · 3106 阅读 · 3 评论 -
we are unable to locate the App Tracking Transparency permission request when reviewed on iOS 15.0.2
App Store审核被拒内容如下:Guideline 2.1 - Information NeededWe’re still looking forward to completing our review, but we need more information to continue. Your app uses the AppTrackingTransparency framework, but we are unable to locate the App Tracking Transpar原创 2021-10-20 11:08:10 · 1373 阅读 · 0 评论 -
【iOS开发】相册选择图片识别条形码
【iOS开发】相册选择图片识别条形码原生识别条形码VNDetectBarcodesRequest 只要iOS11.0+以上支持,支持iOS11.0-以下请使用其他方案 // Create a barcode detection-request let barcodeRequest = VNDetectBarcodesRequest(completionHandler: { request, error in guard let results = request.re原创 2021-09-14 16:30:48 · 957 阅读 · 0 评论 -
iOS根据相册图片识别条形码、二维码以及脸部特征
iOS根据相册图片识别条形码、二维码以及脸部特征原生识别二维码 // 获取二维码 func WM_FUNC_getQrCode(qrcodeImg:UIImage) -> Void { if let img:CIImage = CIImage.init(image: qrcodeImg) { if let qrDetector = CIDetector.init(ofType: CIDetectorTypeQRCode, context: n原创 2021-09-13 16:34:18 · 1006 阅读 · 0 评论 -
Guideline 2.5.4 - Performance - Software Requirements关于UIBackgroundModes被拒问题
Guideline 2.5.4 - Performance - Software Requirements关于UIBackgroundModes被拒问题记一次审核被拒的过程被拒内容如下:2021年8月27日 上午8:36发件人 Apple2. 5 Performance: Software RequirementsGuideline 2.5.4 - Performance - Software RequirementsYour app declares support for locati原创 2021-08-27 10:46:36 · 1912 阅读 · 0 评论 -
iOS14.0+解决UITextField 中 leftView和rightView设置控件宽高无效的问题
iOS14.0+解决UITextField 中 leftView和rightView设置控件宽高无效的问题iOS14.0+ UITextField 中 leftView和rightView设置UILabel、UIButton、UIImageView等控件的宽高无效问题现象小于iOS14.0,UILabel、UIButton、UIImageView等控件设置宽高有效,iOS14.0+,设置宽高无效,解决方案同下即可。解决方案:1、创建UIView的父视图,然后把UILabel、UIButton原创 2021-07-12 14:45:15 · 2010 阅读 · 0 评论 -
[转]iOS组件化开发方案
将一个工程分解成各个组件,然后按照某种方式任意组织成为一个拥有完整业务逻辑的工程。大致讨论组件化的三种方案:url-block、protocol-class(和 url-controller 类似)、target-action,以及应用这三种组件化方案的时机、步骤、利弊等。一、为什么需要组件化随着公司业务的不断发展,项目的功能越来越复杂,各个业务代码耦合越来越多,代码量急剧增加,传统的 MVC 或者 MVVM 架构已经无法高效的管理工程代码,因此需要用一种技术来更好地管理工程,而组件化是一种能够解.原创 2021-07-11 11:51:05 · 360 阅读 · 1 评论 -
WKWebView 遇到 NSInternalInconsistencyException runJavaScriptAlertPanelWithMessage: was not called
WKWebView 遇到 NSInternalInconsistencyException runJavaScriptAlertPanelWithMessage: was not calledCompletion handler passed to -[xxx.BaseWebViewController webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:] was not called从 cra原创 2021-06-25 17:41:43 · 1756 阅读 · 0 评论 -
iOS How to set status bar style
How to set status bar styleGloballyIf you want to change the status bar style to all of your view controllers, you can do it globally with the help of Info.plist.The default color of the status bar is black text.Default status barTo change the status原创 2021-06-03 11:19:36 · 321 阅读 · 0 评论 -
【iOS开发】一个简单的拖拽悬浮按钮的实现
【iOS开发】一个简单的悬浮按钮的实现直接上图:实现原理使用UIButton的点击事件和手势来实现//// WMMoveButton.swift// moveBtn//// Created by wumeng on 2019/8/22.// Copyright © 2019 wumeng. All rights reserved.//import UIKitenum WMAssistiveType { case none case nearLeft原创 2021-05-18 17:30:27 · 1033 阅读 · 0 评论 -
iOS上架被拒-Guideline 5.1.1 - Legal - Privacy - Data Collection and Storage AppTrackingTransparency
iOS上架被拒-Guideline 5.1.1 - Legal - Privacy - Data Collection and Storage AppTrackingTransparency AppTrackingTransparencyGuideline 5.1.1 - Legal - Privacy - Data Collection and StorageWe noticed that your app requests the user’s consent to access the原创 2021-05-18 11:50:56 · 1529 阅读 · 0 评论 -
iOS Swift CollectionView 列表与网格布局之间切换(带动画)
iOS Swift CollectionView 列表与网格布局之间切换(带动画)//// ViewController.swift// ChangeList//// Created by wumeng on 2021/5/7.//import UIKitlet SCREEN_WIDTH = UIScreen.main.bounds.size.widthlet SCREEN_HEIGHT = UIScreen.main.bounds.size.heightclass Vie原创 2021-05-07 11:36:54 · 620 阅读 · 0 评论 -
【iOS开发】UITableView中dequeueReusableCell带indexpath方法和不带的区别
官方的描述: open func dequeueReusableCell(withIdentifier identifier: String) -> UITableViewCell? // Used by the delegate to acquire an already allocated cell, in lieu of allocating a new one. @available(iOS 6.0, *) open func dequeueReusableCell(wit原创 2021-03-03 15:30:39 · 1148 阅读 · 1 评论 -
[iOS]UITableView的如何使用deleteRows 和 insertRows 动画
使用deleteRows 和 insertRows 动画 if #available(iOS 11.0, *) { self.tableView?.performBatchUpdates({ self.tableView?.deleteRows(at: [indexpath], with: UITableView.RowAnimation.fade) }, completion: { (isfinish) in self.tableView?.re原创 2021-01-12 15:11:32 · 1704 阅读 · 0 评论 -
[iOS开发] Swift5.x 字符串(String)处理
截取字符串swift5.xvar str = "01234567890"let start = str.index(str1.startIndex, offsetBy: 1)let end = str.index(str1.startIndex,offsetBy:6)// str = str.substring(with: start..<end) //swift4 已经废除print("start - end str = \(String(str[start..<end]))"原创 2020-11-19 18:35:03 · 1040 阅读 · 0 评论 -
swift 5.0 字符串md5加密
fileprivate extension String { /* ################################################################## */ /** - returns: the String, as an MD5 hash. */ var md5: String { let str = self.cString(using: String.Encoding.utf8) .原创 2020-11-17 11:30:52 · 1355 阅读 · 0 评论 -
[iOS开发] swift4.0+的字符串的处理
截取字符串swift4.0+var str = "01234567890"let start = str.index(str1.startIndex, offsetBy: 1)let end = str.index(str1.startIndex,offsetBy:6)// str = str.substring(with: start..<end) //swift4 已经废除print("start - end str = \(String(str[start..<end]))原创 2020-11-17 11:07:56 · 114 阅读 · 0 评论 -
IOS13的新特性,模态弹出禁用和启动下滑返回、全屏
今天遇到,模态弹出下滑返回,下滑返回和我本身的画图页面的滑动手势冲突,于是禁用下滑返回。let autoGraphVc = AutoGraphVC()autoGraphVc.delegate = selfautoGraphVc.modalPresentationStyle = UIModalPresentationStyle.fullScreen;if #available(iOS 13.0, *) { autoGraphVc.isModalInPresentation = false}原创 2020-05-20 11:57:38 · 4410 阅读 · 0 评论 -
Swift获取对象的类型
Swift获取对象的类型的方法type(of: <#T##T#>)// type(of: <#T##T#>)eg:let date = Date()type(of: date) // Foundation.Date.Typeprint("\(type(of: date))") // Datelet str = "12345"type(of: str)...原创 2019-12-02 11:40:32 · 1797 阅读 · 0 评论 -
Swift获取文件大小
最近在项目里面,有做的获取文件大小的功能。所以就在在这儿分享一下。swift3.0func sizeForLocalFilePath(filePath:String) -> UInt64 { do { let fileAttributes = try FileManager.default.attributesOfItem(atPath: filePath) ...原创 2019-12-02 11:10:35 · 1808 阅读 · 0 评论 -
如何在Swift中导入全局的框架(Framework)?
如何在Swift中导入全局的框架(Framework)?我们再做项目的过程中,不可避免的想使用像OC中在.h导入一次,就能全局使用的第三方类库。在Swift中强烈建议不要这样做,因为那样会在模块之间引入隐式耦合。1、在桥接OC的.h文件里面导入#import <PodName/PodName-Swift.h>2、声明一个类别名可以通过在导入另一个模块的模块中声明一个类...原创 2019-11-28 09:44:48 · 4090 阅读 · 2 评论 -
macOS10.15如何查看苹果手机的UDID、序列号、型号、IMEI等信息
macOS10.15查看苹果手机的UDID、序列号、型号、IMEI等信息,由于iTunes已经成了过去时,被拆分成了音乐app、视频app、博客app。查看手机信息也放到坊达(finder)-> 位置1、点击访达2、找到位置,选择你连接的手机,点击验证3、点击信息一栏,就能看到你想要的信息了...原创 2019-11-27 12:59:27 · 8350 阅读 · 0 评论 -
iOS仿微信录像和拍照(swift5.0)
WMVideo仿微信录像和拍照,record Video and photo functions exporter源码地址使用 let vc = WMCameraViewController()// vc.inputType = .video vc.videoMaxLength = 20 vc.completeBlock = {...原创 2019-11-27 11:08:15 · 843 阅读 · 0 评论 -
iOS保存视频、图片到相册
保存图片swift 4.0 //MARK:- save image func WM_FUNC_saveImage(_ image:UIImage) -> Void { UIImageWriteToSavedPhotosAlbum(image, self, #selector(image(_:didFinishSavingWithError:contextInfo:...原创 2019-11-21 16:15:13 · 2730 阅读 · 1 评论 -
WKWebView无法加载带有#的URL
今天在做项目中,遇到用WKWebView加载url,无法访问。最后发现是url里面的#被编码成%23导致无法访问https://127.0.0.1/#/?name=华为编码之后:https://127.0.0.1/%23/?name=%E5%8D%8E%E4%B8%BA当 # 号被编译成 %23 之后无法访问解决办法:禁止 **# ** 号编译成 **%23 **OCNSSt...原创 2019-11-11 16:34:34 · 2450 阅读 · 0 评论 -
Xcode 导入和导出自定义代码块(Code Snippets)
Xcode导入和导出自定义代码块我们可以在以下路径找到我们的自定义代码段 ~/Library/Developer/Xcode/UserData/CodeSnippets/.由于库是一个隐藏的文件夹,我们可以使用终端命令打开此路径:open ~/Library/Developer/Xcode/UserData/CodeSnippets/或者,您可以让Finder用终端逗号显示隐藏文件...原创 2019-10-23 16:24:42 · 2290 阅读 · 0 评论 -
Swift 循环引用 小结
在项目中自己写出了一个循环引用的典型例子,如下Viewcontrollerclass FirstViewController: UIViewController { var baseView:BaseView? override func viewDidLoad() { super.viewDidLoad() // Do any ad...原创 2019-09-02 11:49:55 · 321 阅读 · 0 评论 -
UITableViewCell实现自动约束布局出现的警告
我的项目出现了这样的警告:&lt;NSLayoutConstraint:0x171695e50 'UIView-Encapsulated-Layout-Height' \U00c2\U220f\U00c6\U00c2\U00c6\U2202\U00c2\U220f\U00e0\U00c2\U00c7\U00d6.ReceiveOrderTableViewCell:0x14e228200'Mob...原创 2018-07-27 11:12:51 · 1444 阅读 · 0 评论 -
关于cocoapods遇到"xxxx" file not found和No such module 'XXX'的问题
昨天需要引入第三方执行了一下pod install然后发现出现了一下错误'AliyunOSSiOS/OSSService.h' file not found由于我的项目比较特殊,有两个target。在运行之后,发现在编译的项目的时候pods的第三方没有预先在编译app之前编译。 这时候就找到原因,然后分析,为什么pods的第三方没有预先编译呢? 原来pods___.fram...原创 2018-06-20 12:13:34 · 13483 阅读 · 0 评论 -
【ios开发】导航栏添加左右按钮出现右移的解决方案
解决导航栏,添加按钮,布局右移的问题 let spaceButtonItem = UIBarButtonItem.init(barButtonSystemItem: .fixedSpace, target: self, action: nil); spaceButtonItem.width = -15; let leftBtn = UIButton.i...原创 2018-06-22 16:11:12 · 951 阅读 · 0 评论 -
Swift4关于Codable的介绍和使用
Codable的Encoding和Decoding自定义类型使您的数据类型可编码(encodable)和可解码(decodable),以与外部表示(如JSON)兼容。概述许多编程任务涉及通过网络连接发送数据,将数据保存到磁盘或将数据提交给API和服务。这些任务经常要求数据在传输过程中被编码和解码成中间格式。Swift标准库定义了一种数据编码和解码的标准方法。您通过在自定义类型上实现Encodable翻译 2018-01-18 20:35:07 · 4123 阅读 · 0 评论 -
iOS内嵌WKWebView拨打电话、发短信、发邮件没反应
iOS内嵌WKWebView拨打电话没反应 a href="tel:13112345678">拨打号码a> 内嵌H5的发送短信,打电话,发送邮件代码的处理 实现webview的代理方法swift3.0 代码: // 处理拨打电话、发短信、发邮件以及Url跳转等等 func webView(_ webView: WKWebView, decidePolicyFor原创 2018-01-25 17:07:39 · 6333 阅读 · 0 评论