小编Ale*_*lff的帖子

UITextView从文本的底部或中间开始

我会正确的.我有一个UItextView放置在我的视图中,当需要滚动查看所有文本时(当textView中存在大量文本时)textView有时会在文本的中间开始,而文本的底部则会在其他时间开始.

在此输入图像描述

textView上未启用编辑.我需要一种方法来强制textView每次都从顶部开始.我看到一些问题,其他人使用内容偏移,但我真的不知道它是如何工作的,或者它是否适用于此处.

谢谢你的帮助.

xcode cocoa-touch objective-c ios swift

75
推荐指数
8
解决办法
3万
查看次数

将Image转换为CVPixelBuffer以进行机器学习Swift

我试图让在2017 WWDC上演示的Apple样本Core ML模型正常运行.我正在使用GoogLeNet来尝试对图像进行分类(请参阅Apple Machine Learning Page).该模型将CVPixelBuffer作为输入.我有一个名为imageSample.jpg的图像,我正用于此演示.我的代码如下:

        var sample = UIImage(named: "imageSample")?.cgImage
        let bufferThree = getCVPixelBuffer(sample!)

        let model = GoogLeNetPlaces()
        guard let output = try? model.prediction(input: GoogLeNetPlacesInput.init(sceneImage: bufferThree!)) else {
            fatalError("Unexpected runtime error.")
        }

        print(output.sceneLabel)
Run Code Online (Sandbox Code Playgroud)

我总是在输出中获得意外的运行时错误,而不是图像分类.我转换图片的代码如下:

func getCVPixelBuffer(_ image: CGImage) -> CVPixelBuffer? {
        let imageWidth = Int(image.width)
        let imageHeight = Int(image.height)

        let attributes : [NSObject:AnyObject] = [
            kCVPixelBufferCGImageCompatibilityKey : true as AnyObject,
            kCVPixelBufferCGBitmapContextCompatibilityKey : true as AnyObject
        ]

        var pxbuffer: CVPixelBuffer? = nil
        CVPixelBufferCreate(kCFAllocatorDefault,
                            imageWidth,
                            imageHeight,
                            kCVPixelFormatType_32ARGB,
                            attributes as …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch machine-learning ios swift coreml

19
推荐指数
2
解决办法
9420
查看次数

FireBase Cocoa Pods安装不起作用

我正在尝试通过Cocoa Pod为我的Objective-C iOS应用程序安装Firebase.我的Podfile如下:

target 'RandomName' do

pod 'Firebase/Core'
pod 'Firebase/AdMob'

end
Run Code Online (Sandbox Code Playgroud)

当我运行时pod install,我收到以下错误:

[!] Unable to satisfy the following requirements:

- `Firebase/Core` required by `Podfile`

None of your spec sources contain a spec satisfying the dependency: `Firebase/Core`.

You have either:
 * out-of-date source repos which you can update with `pod repo update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, `pod repo …
Run Code Online (Sandbox Code Playgroud)

ios cocoapods firebase

17
推荐指数
2
解决办法
2万
查看次数

从ARCamera获取相机翻译

我正在尝试使用Apple的ARKit,并且对相机的转换有疑问。转换矩阵中的哪个值代表用户从原点走了多远?呼唤

self.sceneView.session.currentFrame!.camera.transform.columns.0.x 
Run Code Online (Sandbox Code Playgroud)

似乎无法产生正确的X翻译。

此外,什么是正确的位置YZ

cocoa-touch matrix augmented-reality swift arkit

3
推荐指数
1
解决办法
1140
查看次数