Tag: 迅速

如何使用Swift,iOS 7设置rootViewController

我想在应用程序委托中设置rootViewController .. func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { var rootView: MyRootViewController = MyRootViewController() //Code to set this viewController as the root view?? return true }

应用程序崩溃只在Testflight生成

我在swift上创build了一个应用程序,并使用iPhone 6,iPhone 6 plus和iPhone 5设备以及Xcode中提供的所有模拟器进行了广泛的testing。 该应用程序运行良好,并不会在本地上传时崩溃。 (iOS 8) 我终于提交了一个TestFlight的构build。 通过Testflight构build下载应用程序后,该应用程序在相同的地方始终崩溃。 上传的版本与本地创build的版本运行方式有什么不同吗? 我怎样才能debugging与Testflight构build的问题?

'必需的'初始化'init(coder :)'必须由'UITableViewCell'`的子类提供

据说这个代码在这里和这里工作 ,但我似乎无法使其工作。 IBOutlets连接到故事板中的对象。 prototypeCell被命名,所以我可以使用它与dequeueReusableCellWithIdentifier和它的自定义类属性设置为commentCell 。 第一个错误(我可以解决,但上面的链接都不需要它,这让我觉得我做错了什么,对吗?): Overriding method with selector 'initWithStyle:reuseIdentifier:' has incompatible type '(UITableViewCellStyle, String) -> commentCell' 第二个错误(有趣的错误): 'required' initializer 'init(coder:)' must be provided by subclass of 'UITableViewCell'` 单元分类代码: class commentCell: UITableViewCell { @IBOutlet weak var authorLabel: UILabel! @IBOutlet weak var commentLabel: UITextView! init(style: UITableViewCellStyle, reuseIdentifier: String) { super.init(style: style, reuseIdentifier: reuseIdentifier) } override […]

如何分发Swift Library而不暴露源代码?

我尝试的第一件事是创build一个静态库,但后来我发现它还不支持。 Apple Xcode Beta 4发行说明: Xcode不支持构build包含Swift代码的静态库。 (17181019) 我希望苹果能够在下一个Beta版本或GA版本中添加这个function,但是我在他们的博客上阅读了以下内容: 尽pipe您的应用程序的运行时兼容性得到了保证,但Swift语言本身将继续发展,二进制接口也将发生变化。 为了安全起见,应用程序的所有组件都应该使用相同版本的Xcode和Swift编译器来构build,以确保它们一起工作。 这意味着框架需要仔细pipe理。 例如,如果您的项目使用框架与embedded式扩展共享代码,则需要一起构build框架,应用程序和扩展。 依赖使用Swift的二进制框架(尤其是来自第三方)是危险的 。 随着Swift的变化,这些框架将与您的应用程序的其余部分不兼容。 当二进制接口在一两年内稳定后,Swift运行时将成为主机操作系统的一部分,这个限制将不再存在。 这个消息让我非常震惊,一个为其他开发者编写组件的人使用并包含在他们的应用程序中。 这是否意味着我必须分发源代码或等待两年? 有没有其他的方式来分发图书馆而不暴露代码(公司政策)? 更新: 在这一点上,Swift代码混淆是一个选项吗?

如何检查iOS设备是否使用Swiftlocking/解锁?

我如何检测使用Swift的locking/解锁的iOS设备(如Android中的SCRENON / SCREENOFF)

我如何使用iOS SDK的Swift REPL

我可以用iOS SDK运行Swift REPL吗? 我想在REPL中导入和使用UIKit ,但没有成功。 $ xcrun –sdk iphonesimulator8.1 –show-sdk-path /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk $ xcrun –sdk iphonesimulator8.1 swift Welcome to Swift! Type :help for assistance. 1> import UIKit /var/folders/kb/xgglxb597sv6h8b744d5vft00000gn/T/lldb/92014/repl1.swift:2:8: error: no such module 'UIKit' import UIKit ^ $ swift -sdk `xcrun –sdk iphonesimulator8.1 –show-sdk-path` Welcome to Swift! Type :help for assistance. 1> import UIKit /var/folders/kb/xgglxb597sv6h8b744d5vft00000gn/T/lldb/91881/repl1.swift:2:8: error: no […]

使用AVFoundation扫描Swift 3.0中的条码或QR码

我正在按照这个教程,并试图将代码从Swift 2.0转换为3.0。 但是当我启动应用程序,该应用程序不起作用! 我的意思是,没有任何反应 这是我的代码: 视图控制器: class ViewController: UIViewController ,BarcodeDelegate { override func prepare(for segue: UIStoryboardSegue, sender: Any?) { let barcodeViewController: BarcodeViewController = segue.destination as! BarcodeViewController barcodeViewController.delegate = self } func barcodeReaded(barcode: String) { codeTextView.text = barcode print(barcode) } } BarcodeVC: import AVFoundation protocol BarcodeDelegate { func barcodeReaded(barcode: String) } class BarcodeViewController: UIViewController,AVCaptureMetadataOutputObjectsDelegate { var […]

在Swift中获取UIImage的平均颜色

我最近试图把这里的代码转换成Swift。 不过,不pipe形象如何,我都会得到一种白色。 这是我的代码: // Playground – noun: a place where people can play import UIKit extension UIImage { func averageColor() -> UIColor { var colorSpace = CGColorSpaceCreateDeviceRGB() var rgba: [CGFloat] = [0,0,0,0] var context = CGBitmapContextCreate(&rgba, 1, 1, 8, 4, colorSpace, CGBitmapInfo.fromRaw(CGImageAlphaInfo.PremultipliedLast.toRaw())!) rgba CGContextDrawImage(context, CGRectMake(0, 0, 1, 1), self.CGImage) if rgba[3] > 0 { var […]

如何合并两个UIImage?

我试图合并两个不同的图像,并创build一个新的。 这是我想要做的方式:我有这样的形象(A): 这是一个PNG图像,我想将这个与另一个图像(B)合并,我从手机中拿出来创build这样的图像: 我需要一个将A与B合并的function.C尺寸必须保留在A图像上,而图像B应该自动调整尺寸以适合宝丽来(A)。 有没有可能做到这一点? 感谢您的帮助! 更新只是一件事,图像(A)是一个正方形,我采取的图像是16:9,我该如何解决? 如果我使用你的function,我所拍摄的图像(B)变得拉长了!

Swift用可选的存储属性初始化Struct

我是一个Swift新手,我试图让我的头在使用具有可选属性的Structs。 我做了很多search,find了一些可行的方法,但是效率却非常低,所以我想知道是否有更好的/更易于pipe理的方式来实现我的目标。 我想用Structs来代表一个企业,但我不知道哪个特定业务可能具有哪些特性的组合。 这似乎意味着我必须为每个可能的参数组合创build一个init()。 这里有一个简单的例子(我有更多的属性): import Foundation struct Business { let name : String var web : String? var address: String? // just the business name init(busName: String) { self.name = busName } // business name + website init(busName: String, website: String) { self.name = busName self.web = website } // business name + address […]