小编GJZ*_*GJZ的帖子

如何将Int数组转换为String?Swift中的数组

我有一个看起来像这样的数组:

var arr: [Int] = [1,2,3,4,5]
Run Code Online (Sandbox Code Playgroud)

为了打印这个,我想将其转换为:

var newArr: [String?] = ["1","2","3","4","5"]
Run Code Online (Sandbox Code Playgroud)

请帮帮我!提前致谢.

arrays casting type-conversion ios swift

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

为什么没有调用textFieldShouldReturn函数?

textFieldShouldReturn根本没有调用该函数:没有错误,但键盘根本没有响应.

我的情况与按下返回键时如何在swift中隐藏键盘不同在我的情况下,根本没有发生任何事情,其他情况都在Objective-C中.

这是我的代码:

import UIKit

class ViewController: UIViewController {

    @IBOutlet var textField: UITextField!

    func textFieldShouldReturn(textField: UITextField) -> Bool {
        resignFirstResponder()
        return true
    }
}
Run Code Online (Sandbox Code Playgroud)

textField是我的故事板上文本字段的出口.我也试过self.endEditing而不是resignFirstResponder.

keyboard swift

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

由于openldap和openssl makefile错误,iOS应用归档失败

我目前正在建设用Objective-C的iOS应用和含有雨燕的OpenSSLOpenLDAP的框架,它建立并没有任何问题运行.

但是,当我尝试将应用程序存档以供发布时,会出现以下错误:

错误

以下是一些其他信息:

  • Xcode版本是7.3.1(7D1014)

  • 该项目是一个Xcworkspace(包含一个podfile,但框架没有通过Cocoapods集成)

更新:

进一步测试后,发生了另一个makefile错误(在任何情况下类似的问题)

第二张图片

此图像说明了所使用的所有框架和库以及发生的错误.

这是构建日志:

更多详情

我感谢任何帮助,并乐意提供任何其他信息.

注意:我仍在寻找答案以解决此问题

xcode openssl openldap ios swift

6
推荐指数
1
解决办法
164
查看次数

从Swift 3中的txt文件中读取

我想知道如何从txt文件中读取并打印出文件的特定部分?

例如,"test.txt"将包含:

'''杰森16男自我编程

约什15男性朋友艺术'''

所以我正在寻找一种分别打印每个单词和行的方法.比如只打印:

"杰森"

"杰森16岁"

"乔希喜欢艺术"

这是我到目前为止搜索的内容

if let filepath = Bundle.main.path(forResource: "test", ofType: "txt")
    {
        do
        {
            let contents = try String(contentsOfFile: filepath)
            print(contents[0])

        }
        catch
        {
            // contents could not be loaded
        }
    }
    else
    {
        // example.txt not found!
    }
Run Code Online (Sandbox Code Playgroud)

感谢您的支持.

file swift swift3

5
推荐指数
1
解决办法
7552
查看次数

如何使用Swift将自定义字体添加到iOS中的imglyKit SDK中?

我尝试了以下代码将自定义字体添加到imglyKit SDK中,但没有添加自定义字体.我还将.ttf文件作为资源放入info.plist文件中.

        let sampleImage = image.image

    let configuration = Configuration() { builder in
        FontImporter.init().importFonts()

        builder.configurePhotoEditorViewController({ (editPhotoOption) in

            editPhotoOption.allowedPhotoEditorActions = [.text]

            editPhotoOption.actionButtonConfigurationClosure = {cell, _ in

                cell.captionLabel.text = "Add Text"
                //cell.backgroundColor = UIColor.red
            }
            editPhotoOption.backgroundColor = UIColor.brown
            editPhotoOption.allowsPreviewImageZoom = false            
        })

        builder.configureToolStackController({ (toolStackOption) in

            toolStackOption.mainToolbarBackgroundColor = UIColor.red
            toolStackOption.secondaryToolbarBackgroundColor = UIColor.brown

        })

        builder.configureTextFontToolController({ (textFontToolOption) in

            var fontArray = [String]()
            fontArray = ["AlexBrush_Regular.ttf", "Arabella.ttf"]
            textFontToolOption.accessibilityElements = fontArray

            textFontToolOption.actionButtonConfigurationClosure = { cell, _ in
                cell.backgroundColor = UIColor.red
            }                
        })


        builder.configureTextToolController({ (textToolOption) in

            textToolOption.textViewConfigurationClosure = …
Run Code Online (Sandbox Code Playgroud)

fonts ios imgkit swift

5
推荐指数
1
解决办法
259
查看次数

标签 统计

swift ×5

ios ×3

arrays ×1

casting ×1

file ×1

fonts ×1

imgkit ×1

keyboard ×1

openldap ×1

openssl ×1

swift3 ×1

type-conversion ×1

xcode ×1