小编And*_*ini的帖子

在Swift 3中滑动手势

我试图让UISwipeGestureRecognizer在Swift 3中工作,默认滑动右边工作正常但不向上或向左.

我通过控制拖动Action来尝试它

@IBAction func hole(_ recognizer: UISwipeGestureRecognizer) {
    if (recognizer.direction == UISwipeGestureRecognizerDirection.left)
    {
        print("left")
    }else if recognizer.direction == .right {
        print("right")
    }else {
        print("other")
    }
}
Run Code Online (Sandbox Code Playgroud)

而且,在ViewDidLoad中

//gesture recognisers
let swipeRight = UISwipeGestureRecognizer(target: self, action: "holeSwiped:")
swipeRight.direction = UISwipeGestureRecognizerDirection.right
self.view.addGestureRecognizer(swipeRight)

let swipeLeft = UISwipeGestureRecognizer(target: self, action: "holeSwiped:")
swipeLeft.direction = UISwipeGestureRecognizerDirection.left
self.view.addGestureRecognizer(swipeLeft)
Run Code Online (Sandbox Code Playgroud)

我的方法

func holeSwiped(gesture: UISwipeGestureRecognizer)
{
    if let swipeGesture = gesture as? UISwipeGestureRecognizer{
        switch swipeGesture.direction {
        case UISwipeGestureRecognizerDirection.right:
            print("right swipe")
        case UISwipeGestureRecognizerDirection.left:
            print("left swipe")
        default:
            print("other swipe")
        }
    } …
Run Code Online (Sandbox Code Playgroud)

swift

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

如何在swift playground中使用用carthage导入的框架

我有一个快速的项目,通过carthage添加了一些框架.是否可以在项目内的游乐场中使用这些框架以及如何使用它,因为

import Argo
Run Code Online (Sandbox Code Playgroud)

不起作用:(

xcode swift swift-playground carthage

14
推荐指数
2
解决办法
4106
查看次数

CloudKit:获取具有特定记录类型的所有记录?

我目前在我的应用程序中设置了CloudKit,以便我使用以下代码的帮助添加新记录,

CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName:@"stringArray"];
CKRecord *record = [[CKRecord alloc] initWithRecordType:@"Strings" recordID:recordID];
[record setObject:[NSArray arrayWithObjects:@"one", @"two", @"three", @"four", nil] forKey:@"stringArray"];
[_privateDatabase saveRecord:record completionHandler:nil];
Run Code Online (Sandbox Code Playgroud)

但是,现在我希望能够获取具有相同记录类型的所有记录"Strings",并将这些记录返回到NSArray中.我该怎么做呢?目前,我所知道的是如何使用recordID单独获取每条记录,这是一个麻烦,必须有一个更简单的方法.

[_privateDatabase fetchRecordWithID:recordID completionHandler:^(CKRecord *record, NSError *error) {
   if (error) {
      // Error handling for failed fetch from private database
   }
   else {
      NSLog(@"ICLOUD TEST: %@", [record objectForKey:@"stringArray"]);            
  }
}];
Run Code Online (Sandbox Code Playgroud)

ios icloud cloudkit ckrecord

11
推荐指数
2
解决办法
7678
查看次数

Xcode Playgrounds显示"空图像"

我今天下载了Xcode 9.2,不可否认,我有一段时间没试图这样做,我试图在操场上渲染一个视图,并在侧边栏中不断获得"空图像".

谁知道怎么了?

在此输入图像描述

ios swift swift-playground xcode9.2

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

ARkit - 从SCNScene中的Web服务器URL加载.scn文件

我正在为我的应用程序使用ARKit,我尝试从我的web服务器(URL)动态加载.scn文件

这是我的代码的一部分

 let urlString = "https://da5645f1.ngrok.io/mug.scn"
        let url = URL.init(string: urlString)
        let request = URLRequest(url: url!)
        let session = URLSession.shared
        let downloadTask = session.downloadTask(with: request,
                completionHandler: { (location:URL?, response:URLResponse?, error:Error?)
                -> Void in
                print("location:\(String(describing: location))")
                let locationPath = location!.path
                let documents:String = NSHomeDirectory() + "/Documents/mug.scn"
                ls = NSHomeDirectory() + "/Documents"
                let fileManager = FileManager.default
                if (fileManager.fileExists(atPath: documents)){
                     try! fileManager.removeItem(atPath: documents)
                }
                try! fileManager.moveItem(atPath: locationPath, toPath: documents)
                print("new location:\(documents)")
                let node = SCNNode()
                let scene =  SCNScene(named:"mug.scn", inDirectory: ls)
                let nodess …
Run Code Online (Sandbox Code Playgroud)

ios swift scnnode scnscene arkit

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

iOS如何为每个UIWebView请求添加cookie?

我需要使用Angular打开URL,UIWebView我需要为每个UIWebView请求发送cookie .

我试图做的:

我试图检查请求是否包含cookie.如果它确实UIWebView执行请求,如果不是,我创建相同的请求,但使用cookie并执行它.用我用UIWebViewDelegate的方法替换请求func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool.但它不像我预期的那样工作,有些请求没有cookie.

我的代码:

final class FieldServiceViewController: UIViewController {

    private var webView = UIWebView()
    private var sessionID = String()

    override func viewDidLoad() {
        super.viewDidLoad()

        _ = JSONAPI.getSessionID().subscribe(onNext: { [weak self] sessionID in
            self?.sessionID = sessionID
            self?.configureUI()
            let string = "https://someURL"
            let url = URL(string: string)
            let request = URLRequest(url: url!)
            self?.webView.loadRequest(request)
        })
    }

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        webView.frame …
Run Code Online (Sandbox Code Playgroud)

cookies uiwebview ios swift

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

如何使用iOS 10,Xcode 8中的iMessage应用程序处理OAuth样式的登录?

我正在为iOS 10设置一个需要登录社交网络的iMessage应用程序.在传统的iOS应用程序中,我们通常在AppDelegate中配置带有app id的共享实例...我还需要处理回调URL:传统上放置在AppDelegate中的2个方法(下面).

使用iMessage app/extension,没有AppDelegate.我在哪里可以放置此代码?我能够在应用程序ID配置willBecomeActiveMessagesViewController并没有得到一个实例回来了,但我也把这些方法MessagesViewController与破发点,他们从来不被称为,我相信这是防止我的成功日志中,任何帮助深表感谢!

更新:我最大的问题,甚至在弄清楚如何处理callBack之前就是如何没有openURL方法可用,有一些关于扩展的方法,但我没有成功提出任何建议的解决方案: openURL不起作用在行动扩展中

我看到它要么(1)找到一种方法在我的iMessage扩展中调用openURL,这样我就可以让SDK处理OAuth(2)创建我自己的webview,推送到网站,登录用户,存储令牌和segue回到我的应用程序(似乎没必要)或(3)创建一个iPhone应用程序,只是为了登录(即iMessage扩展打开的父应用程序和登录),再次似乎没有必要).当然,这在iMessage扩展中会很常见吗?

func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool {
}

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {   
}
Run Code Online (Sandbox Code Playgroud)

oauth ios swift

7
推荐指数
0
解决办法
352
查看次数

如何在carthage上安装旧版本

我需要使用carthage来运行Appium测试.虽然Appium社区仍在努力支持XCode9.2,但我们需要依赖XCode 8.3.3 OS:MacOS High Sierria XCode版本:XCode 8.3.3 Java:1.9

但是当我运行命令brew install carthage时,我得到以下错误:

Error: Your Xcode (8.3.3) is too outdated.
Run Code Online (Sandbox Code Playgroud)

请参考下面的链接,这意味着-XCode9对Appium的支持尚未推出

[ https://github.com/facebook/WebDriverAgent/issues/639] [1 ]

请建议同时解决.谢谢

xcode ios appium carthage appium-ios

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

UITableView禁用滑动以删除特定单元格swift

我正在尝试禁用滑动以删除tableview中某些特定单元格的操作.但我无法在迅捷中找到一个好的解决方案.当覆盖"tableView.isEditing = true"方法时,我不希望单元格上的左侧减号.这是我的代码.下面的代码没有禁止滑动到statusId为"12"的单元格.希望你能理解我的问题.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "identifier", for: indexPath) as! TableViewDateCell
    cell.titleStatus.text = mainList[indexPath.row].statusName
    //tableView.isEditing = true
    //disable swipe to delete for cell with statusId == "12"
    if mainList[indexPath.row].statusId == "12" {
         //tableView.isEditing = false
        cell.selectionStyle = UITableViewCellSelectionStyle.gray
        cell.isUserInteractionEnabled = false

    }
 }


func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {

}
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

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

无法到达Firestore后端

我正在创建一个swift 4 ios应用程序,并希望使用Firestore来存储我的所有数据.我已经阅读了入门指南并观看了在线教程,但我仍然收到错误消息:

"4.8.1 - [Firebase/Firestore] [I-FST000001]无法访问Firestore后端."

我的cocoapods文件包含:

pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
Run Code Online (Sandbox Code Playgroud)

AppDelegate:我import FirebasedidFinishLaunchingWithOptionsFirebaseApp.configure()

在viewController中:( import Firebase也试过import FirebaseFirestore)

我定义:

var docRef : DocumentReference! 
Run Code Online (Sandbox Code Playgroud)

并在viewDidLoad中:

docRef = Firestore.firestore().document("test/test")

docRef.getDocument { (docSnapshot, error) in
   guard let docSnapshot = docSnapshot, docSnapshot.exists else {return}
   let myData = docSnapshot.data()
   let val = myData!["name"] as? integer_t ?? 1
   print(val)
}
Run Code Online (Sandbox Code Playgroud)

我得到了错误

"4.8.1 - [Firebase/Firestore] [I-FST000001]无法访问Firestore后端."

我将我的firestore设置为测试模式,因此应允许所有读写操作.任何想法为什么我无法连接到后端?

ios firebase swift swift4 google-cloud-firestore

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