小编izi*_*461的帖子

iOS 模拟器 - 以编程方式禁用连接硬件键盘

我正在编写依赖于显示软件键盘的 UITests。由于 CI 每次都会在全新的模拟器上启动测试,该模拟器已连接硬件键盘,因此不会提供软件键盘。

是否可以设置一些设置(可能在架构中?)以强制禁用模拟器连接硬件键盘。

我正在使用 Cucumber/appium 运行测试。

cucumber ios appium

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

UIPickerView accessiblityLabelForComponent 未被调用

我正在尝试为UIPickerView组件设置可访问性标签,但从未调用过委托方法。更重要的是,UIInspector 显示pickerView 不可访问,但它实际设置了标签。

数据源/委托方法被触发。只有UIAccessibilityDelegate不是。

在 xcode 10.1 iOS 12.1 模拟器上测试

class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate, UIPickerViewAccessibilityDelegate {

    @IBOutlet weak var pickerView: UIPickerView!

    override func viewDidLoad() {
        super.viewDidLoad()
        pickerView.isAccessibilityElement = true
        pickerView.accessibilityLabel = "TESTAccLabel"
    }

    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return 5
    }

    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 2
    }

    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        return "\(component) - \(row)"
    }

    func …
Run Code Online (Sandbox Code Playgroud)

uipickerview uikit ios swift

5
推荐指数
0
解决办法
322
查看次数

Fastlane 选择了错误的配置文件

我已经为我的 iOS 项目配置了 2 个目标和几个配置(第一个目标为 6 个,第二个目标为调试和发布)。

每个版本配置都有不同的 bundleID,因此选择了适当的临时分发配置文件(在gym 命令中):

desc "Build target1-config1"
  lane :deployTarget1 do
    gym(
      workspace: "myProj-ios.xcworkspace",
      scheme: "target1-config1",
      configuration: "target1-Release",
      export_method: "ad-hoc",
      export_options: {
        provisioningProfiles: {  
          "com.target1.config1" => "AdHocProvProfile1"
        }
      },
      output_directory: "./build",
      output_name: "target1-config1.ipa"
      )
    firebase_app_distribution(
      app: "xxxxxxxx",
      groups: "ios_app_testers",
      release_notes: "Automatic dev build from develop",
      firebase_cli_path: "/usr/local/bin/firebase",
      debug: true
      )
  end 
Run Code Online (Sandbox Code Playgroud)

尝试使用 AdhocProvProfile2 构建 target2 时,收到错误消息。看起来 fastlane 没有正确选择 provProfile(和 bundleID!)。此外,在项目设置中正确选择了配置文件。什么可能导致问题?没有外部健身房文件。

 There seems to be a mismatch between your provided `export_method` in gym
[11:15:55]: and the …
Run Code Online (Sandbox Code Playgroud)

xcode ios provisioning-profile fastlane

5
推荐指数
0
解决办法
891
查看次数

iOS 暗模式 - 图像资产未重绘

我正在为 iOS 实现暗模式。图像出现问题:

  • 我打开了 Assets.xcassets 并将“外观”更改为“任何,黑暗”
  • 当然,我已经添加了新图像。

不幸的是,在 xcode 中覆盖环境界面样式时,图像不会被重绘。

我已经尝试在我的 viewController 中捕获 traitCollectionDidChange 方法并且它被正确调用。我可以设置新图像(origImage_dark),但它不应该是自动的吗?这就是资产设置的目的。我正在使用图像的 .alwaysOriginal 渲染。

xcode ios ios-darkmode

4
推荐指数
1
解决办法
1189
查看次数

在CGContext中绘制UIView

我正在尝试画简单UIViewCGContext. 我正在正确绘制字符串,但未UIView绘制字符串。

绘制视图的方法:

view.draw(view.layer, in: context)
Run Code Online (Sandbox Code Playgroud)

但这不起作用。还有其他方法可以画aUIViewCGContext

import UIKit
import CoreGraphics

let contextSize = CGSize(width: 400, height: 400)

UIGraphicsBeginImageContextWithOptions(contextSize, false, 0.0)

guard let context = UIGraphicsGetCurrentContext() else {
    fatalError("no context")
}

let size = CGSize(width: 30, height: 20)
let point = CGPoint(x: 20, y: 240)
let rect = CGRect(origin: point, size: size)

let text = "TEST"
let paragraphStyle = NSMutableParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
paragraphStyle.minimumLineHeight = UIFont.systemFont(ofSize: 6).lineHeight
paragraphStyle.lineBreakMode = .byWordWrapping
paragraphStyle.alignment …
Run Code Online (Sandbox Code Playgroud)

core-graphics cgcontext ios swift

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