标签: xcode8

如何在 Xcode 8.2 的 Playground 项目中使用 Swift 获取用户的输入?

我正在尝试从 iOS 游乐场中的用户获取动态输入,但它不起作用。我尝试了以下代码,但没有成功。

import Foundation
import UIKit
func input() -> String {
    var keyboard = FileHandle.standardInput
    var inputData = keyboard.availableData
    var strData = NSString(data: inputData, encoding: String.Encoding.utf8.rawValue)!

    return strData.trimmingCharacters(in: NSCharacterSet.newlines)
}

input()
Run Code Online (Sandbox Code Playgroud)

ios swift xcplayground xcode8

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

图像视图 - 在启动屏幕上的所有设备上将图像居中对齐

我是 iOS 开发新手。我正在尝试在中心的启动屏幕上添加徽标。我有一个带有渐变颜色的背景,所以我使用了一个 png 文件并将其粘贴在背景中。接下来是我想要为所有设备居中的徽标。

我有两个部分的问题 1)我是否可以指定约束,以便它适用于所有设备?以 % 指定顶部和底部约束的示例?2)如果上述不可能,那么如何将徽标居中对齐,以便它适用于所有设备?我需要在所有设备上单独应用约束吗?

我尝试为所有设备单独设置宽度和高度,但它会修改其他设备上的尺寸。不确定这种方法是否有效或者我使用了错误的东西?

我知道在最坏的情况下,我可以创建带有 png 徽标的启动屏幕,并将它们分别粘贴到每个设备上,这样就可以工作了。我只是想知道是否可以在有限制的情况下完成。

发射机

正如您所建议的,我添加了约束以将其水平和垂直居中对齐。它似乎在一种设备上很好,但在其他设备上却不然。请看下面的图片。

那么如何更改图像大小呢?

一台设备 第二台设备

xcode swift launch-screen swift3 xcode8

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

IOS 图表标签未以数据点为中心。图表库

我目前正在使用 IOS Charts 来制作折线图。

这是它的链接:链接

它的记录非常糟糕,而且我无法将 X 轴标签集中到图表上的绘图上。

我已经启用粒度并将其设置为 1。 - 这可以确保标签不会重复

这是我的图表现在的样子: 在此输入图像描述

这是我想要的样子:在此输入图像描述

我知道点的间距是不同的,但我的主要关注点是如何使标签以正确的数据点为中心。

我的代码:

`导入 UIKit 导入图表

类 ReviewDetailVC: UIViewController, ChartViewDelegate {

@IBOutlet weak var chartView: LineChartView!

var yValues =  [Double]()
var months = [String]()
var xValues = [String]()
let red = UIColor(hue: 0.9639, saturation: 0.62, brightness: 0.93, alpha: 1.0)
let black = UIColor(red:0.29, green:0.29, blue:0.29, alpha:1.0)
let grey = UIColor(red:0.81, green:0.81, blue:0.81, alpha:1.0)

let avenirDemi =  UIFont(name: "AvenirNext-DemiBold", size: 14)
override func viewDidLoad() {
    super.viewDidLoad()

    chartView.delegate …
Run Code Online (Sandbox Code Playgroud)

ios-charts swift3 xcode8

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

ionic cordova build ios 中的新 SubprocessError 错误

我要在Mac上构建ios平台,我遇到了这个问题。

我使用 macOS 10.12、Xcode 8 和 Ionic 4。我已经尝试"ionic cordova platform rm ios""ionic cordova platform add ios"构建,但仍然无法正常工作。

Daos-Mac:Ionic_UI_V1 daovu$ ionic cordova 构建 ios

ng run app:ionic-cordova-build --platform=ios
Run Code Online (Sandbox Code Playgroud)

新的 SubprocessError 错误(/usr/local/lib/node_modules/ionic/node_modules/@ionic/utils-subprocess/dist/index.js:40:23)...

cordova ionic-framework xcode8 ionic4

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

使用 XCode 进行测试时,MacOS 应用程序本地通知未显示

我尝试将横幅通知生成器添加到我的 macOS swift 应用程序中,但在 XCode 中运行测试时,横幅没有出现,并且通知中心中也没有任何新通知可见。我计算机上的其他应用程序会定期生成通知。我错过了什么?我已按要求授予许可

我的应用程序委托如下

class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate {

    @IBOutlet weak var mainMenu: NSMenu!

    func applicationDidFinishLaunching(_ aNotification: Notification)
        {
         NSUserNotificationCenter.default.delegate = self ;
        }

    func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool
        {
        return true
        }

    func applicationWillTerminate(_ aNotification: Notification) {
        // Insert code here to tear down your application
    }
Run Code Online (Sandbox Code Playgroud)

在应用程序启动时,我运行以下方法,并看到控制台行“允许通知”

let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound, .badge, .provisional])
    { granted, error in
    if error != nil
       {
       print ("Request notifications permission Error"); …
Run Code Online (Sandbox Code Playgroud)

macos notifications swift xcode8

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

`curveEaseInOut`在Swift 3中不可用

在swift 3更新中,我收到此错误消息 在此输入图像描述

如果方法调用有任何变化,请告诉我.

谢谢

uiviewanimation swift3 ios10 xcode8

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

分段故障:11; (xcode 8,Swift 3)使用NotificationCenter后

在Xcode 8中获取分段错误

我最近将我的项目迁移到了Swift 3.Xcode Version 8.0(8A218a)每当我使用UIKeyboardWillShow通知时,我都会收到此错误:

由于信号命令失败:分段错误:11`

这就是我在我的代码中使用通知的方式:

override func viewWillAppear(_ animated: Bool) {
    NotificationCenter.default.removeObserver(NSNotification.Name.UIKeyboardWillShow)
    NotificationCenter.default.removeObserver(NSNotification.Name.UIKeyboardWillHide)
    NotificationCenter.default.addObserver(self, selector: #selector(myViewController.keyboardWillShow(_:)), name:NSNotification.Name.UIKeyboardWillShow, object: nil)
    NotificationCenter.default.addObserver(self, selector: #selector(myViewController.keyboardWillHide(_:)), name:NSNotification.Name.UIKeyboardWillHide, object: nil)

}


func keyboardWillShow(_ sender: Notification) {
     //keyboardWillShow Method
}

func keyboardWillHide(_ sender: Notification) {
    // keyboardWillHide Method
}
Run Code Online (Sandbox Code Playgroud)

当我在viewWillAppear方法中注释掉代码时,项目成功运行.

ios notificationcenter swift3 xcode8

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

Xcode构建 - 坚持编译Swift源文件

在Xcode 8 GM中构建我的项目时,Xcode坚持"编译Swift源文件".它也永远不会在任何时候完成我的项目的索引.

我看过类似的问题,但这些答案都不适合我.

有谁知道这可能是什么?

xcode xcode8

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

swift3中的CBC特征值

我是快速发展的初学者.我正在研究基于BLE的应用程序.今天我更新了Xcode 8,iOS 10并将我的代码转换为swift3.然后我的一些语法需要转换.解决这个问题后,我发现了一个关于CBC特性的问题.

问题

在didUpdateValueforCharacteristic中,我可以获得更新的CBC特性对象.如果我打印出整个对象,它会正确显示. - > value = <3a02>当我从CBCharacteristic中检索值时,characteristic.value - > 2bytes(此值的大小)

func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic:     CBCharacteristic, error: Error?)
{
if (characteristic.uuid.description == LED_WAVELENGTH_CHARACTERISTIC_UUID)
{
            print("Characteristic - \(characteristic)")
            print("Data for characteristic  Wavelength - \  (characteristic.value)")
        }
 }
Run Code Online (Sandbox Code Playgroud)

记录结果:

Characteristic - <CBCharacteristic: 0x1742a50a0, UUID = 2C14, properties = 0xE, value = <3a02>, notifying = NO>
Data for characteristic  Wavelength - Optional(2 bytes)
Run Code Online (Sandbox Code Playgroud)

PS:此代码在以前的版本上完全正常工作.

感谢您的关注,希望有人可以帮我解决这个问题.

ios bluetooth-lowenergy cbperipheral swift3 xcode8

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

应用程序的实现:openURL:sourceApplication:annotation

我在Xcode8发布之前开始研究应用程序然后切换,当我尝试使用Facebook登录登录应用程序时出现以下错误

应用程序的实现:openURL:sourceApplication:annotation:not found.请将处理程序添加到App Delegate中.类:GhostGab.AppDelegate

我检查了所有的设置,他们似乎很好.任何帮助将不胜感激

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    FIRApp.configure()
    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    return true
}

  func application(application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {

    let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application(
        application,
        open: url,
        sourceApplication: sourceApplication,
        annotation: annotation)
    // Add any custom logic here.
    return facebookDidHandle
}
Run Code Online (Sandbox Code Playgroud)

facebook ios appdelegate swift xcode8

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