小编Kru*_*nal的帖子

状态栏背景颜色不会更改为自定义颜色

当我将状态栏的背景色更改为本机UIColor.gray时,它也会更改。但是,当我要使用自定义颜色时,它会变成黑色。

UIApplication.shared.statusBarView?.backgroundColor = UIColor.gray-此代码正常工作。状态栏背景颜色为灰色

UIApplication.shared.statusBarView?.backgroundColor = UIColor(red: 30/255, green: 30/255, blue: 30/255, alpha: 1)-此代码无法正常工作。状态栏背景颜色为黑色

colors statusbar ios uistatusbar swift

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

Swift:带有switch语句的嵌套枚举

如何使用switch-case处理嵌套枚举?

我遵循枚举:

enum Parent: Int {

    enum Nested1: Int {
        case Bow
        case Sword
        case Lance
        case Dagger
    }
    enum Nested2: Int {
        case Wooden
        case Iron
        case Diamond
    }

    //case Nested1  -- Not allowed
    //case Nested2  -- Not allowed
    case Case3
    case Case4
    case Case5

}
Run Code Online (Sandbox Code Playgroud)

我怎么能用它来处理它switch-case.

对于父枚举和嵌套枚举,我有两个整数变量.

let parent = 1
let nested = 2
Run Code Online (Sandbox Code Playgroud)

我正在尝试以下方式,但失败了(下面的代码,不起作用).

let parentCase =  Parent(rawValue: parent)

switch parentCase {
case .Nested1:
    print("Weapon")

case .Nested2:
    print("Helmet")
    let nestedCase = Parent.Nested2(rawValue: nested)

    switch …
Run Code Online (Sandbox Code Playgroud)

enums enumeration switch-statement swift

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

Swift:字符串中的子串(整数/数字)

我正在我的应用程序中处理语音识别器模块.语音识别器返回一个字符串(可能有一段时间有垃圾字符串信息,与用户的语音紧密匹配),我必须从字符串中评估特定命令.

以下是我得到的一些语音结果字符串示例:

  • "开放情况"
  • "打开案例1234"
  • "open case id 3421"
  • "打开案例没有9546"
  • "打开案号5241"
  • "开箱9552开箱"
  • "打开案例打开案例6842"
  • "open case bla bla 5415 bla"
  • "打开案例1234 bla bla"
  • "打开案例编号54675 bla bla 1234 bla".//应该在命令中考虑第一个整数

现在,我有一组命令列表,其中一个是命令 open case <Integer value>

我可以open case使用Swift的子字符串实用函数轻松评估一个单词.但问题是,我要从关键字后的语音字符串中找出(识别并获取)整数open case.

我查看了以下答案,但找不到确切的结果/解决方案:

string int substring swift

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

如何重置iOS模拟器?

如何重置iOS模拟器?

在此处输入图片说明

没有选项(子菜单)是带有 Xcode 9.4(测试版 2)的模拟器(菜单),这是在早期的模拟器中。

在此处输入图片说明

我在哪里可以找到它,在模拟器菜单中?

xcode simulator ios ios-simulator xcode9.4-beta

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

iOS应用程序:企业分发/部署 - 缺少app.plist

我正面临部署企业iOS应用程序的问题.

以下是从Web服务下载应用程序的示例链接:'itms-services://?action = download-manifest&url = https://location.company.com/sites/mobile/Files/Mobile/deploy/app.plist '.

我在同一个Web服务器上托管了一个html和ipa文件.

当我尝试从服务器下载应用程序时,我收到一个错误:

"无法连接到服务器"

设备登录Xcode显示,下面的日志:
TOM-iPhone itunesstored [106]:无法加载带有底层错误的下载清单:Error Domain = SSErrorDomain Code = 2"无法连接到iTunes Store"UserInfo = {NSLocalizedDescription =无法连接到iTunes Store}

它表示在以下位置丢失app.plist时 出错:https://location.company.com/sites/mobile/Files/Mobile/deploy/app.plist

如何创建新的app plist?

在这里,我看到了示例plist但是如何为我的应用程序创建plist?

deployment xcode plist ios enterprise-distribution

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

使用Scanner的字符串数组

在我的程序中,我需要创建一个字符串数组,允许用户使用扫描仪在控制台中一个接一个地输出最多100个文本字符串.然后我需要程序能够显示当用户键入单词'stop'时键入的所有字符串(<= 100).

我不是指望任何人为我编写整个程序,但可能只是一些提示?

我确信这是非常基本的,但我对java很新,我不能让这个模块失败,任何帮助都非常感谢!

package assignment2017;

import java.util.Scanner;

public class FootballResultsGenerator {

    public static void main(String[] args) {



        String m = (" : ");
        String promptA = ("Goals scored by: ");
        String resultA = ("Results: ");
        String awayTeamGoals = ("the away teams scored: ");
        String homeTeamGoals = ("the home teams scored: "); 
        String totalGoals = ("Total number of goals: ");

                int numberOfGames=0;

                String lineSplit = ("-------------------------------------------");
        //These are my teams.

        //home
        String ah = ("Tottenham Hotspur(Home)");
        String gh = ("Sunderland(Home)"); …
Run Code Online (Sandbox Code Playgroud)

java arrays string java.util.scanner

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

Swift:在字符串中添加前缀(字符串)

我正在寻找一个String将前缀字符串添加到现有字符串中的函数.

问题我是:有时候,我从没有关键字http的 Web服务响应中获取url字符串.

URL的一般形式(url字符串)应为:http://www.testhost.com/pathToImage/testimage.png

但有时我会//www.testhost.com/pathToImage/testimage.png从网络服务中获得.

现在,我知道我可以检查http:字符串中是否有前缀,但如果没有,那么我需要在现有的url字符串中添加前缀.

是否有任何String(或子字符串或字符串操作)函数在我的url字符串中添加前缀?

我试过Apple文档:String但找不到任何帮助.

我有另一种方法是连接字符串.

这是我的代码:

var imageURLString = "//www.testhost.com/pathToImage/testimage.png"

if !imageURLString.hasPrefix("http:") {
   imageURLString = "http:\(imageURLString)"  // or  "http:"+ imageURLString
}
print(imageURLString)
Run Code Online (Sandbox Code Playgroud)

但是我可以在这里使用任何标准方式或iOS String默认功能吗?

string url prefix ios swift

0
推荐指数
2
解决办法
2522
查看次数

Swift 3数组-在其他数组的帮助下删除多个元素

斯威夫特3:
我有两个数组,一个数组是dictionary(json)的数组,另一个数组是索引Path(具有元素行和节的集合类型Index)的索引(Int值)。借助于第二个数组的索引行,我需要从第一个数组中删除元素。

var arrayString = [ // Array with Json elements
  { "name" : "A" }, 
  { "name" : "B" }, 
  { "name" : "C" }, 
  { "name" : "D" }, 
  { "name" : "E" }, 
  { "name" : "F" }, 
  { "name" : "G" }, 
  { "name" : "H" } 
]
Run Code Online (Sandbox Code Playgroud)

现在第二个数组(将从第一个数组中删除)

var arrayIndex = [ 2, 3, 5 ] // Array with 
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?我想要像这样的结果数组

var arrayString = [ 
       { "name" : "A" }, 
       { "name" : "D" }, 
       { …
Run Code Online (Sandbox Code Playgroud)

arrays closures ios swift swift3

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

iOS XMPP Framwork - libidn.a不包含bitcode

XMPP框架错误

ld:'xmppFrameWork/Vendor/libidn/libidn.a(stringprep.o)'不包含bitcode.您必须在启用bitcode(Xcode设置ENABLE_BITCODE)的情况下重建它,从供应商处获取更新的库,或禁用此目标的bitcode.对于架构arm64

注意:仅在iPhone设备中运行应用程序时出错.(它在模拟器中工作).

xmpp ios xmppframework bitcode

-2
推荐指数
1
解决办法
284
查看次数