小编Mat*_*est的帖子

facebook登录问题 - canOpenURL:网址失败:"fbauth2:///" - 错误:"(null)"

当我点击登录Facebook按钮时,它正在打开safari浏览器并立即关闭.控制台上出现错误.

App委托方法:

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
    print("###### URL : ")
    print(url)
    print("###### App : ")
    print(app)
    print(options["UIApplicationOpenURLOptionsSourceApplicationKey"])
    return FBSDKApplicationDelegate.sharedInstance().application(app, openURL: url,  sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as! String,
            annotation: nil)
}
Run Code Online (Sandbox Code Playgroud)
2015-09-18 18:37:51.410 [21036:5050465] -canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"

2015-09-18 18:37:51.417[21036:5050465] -canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"

###### URL : 

fb4554284912963222://authorize/?error_code=100&error_message=Invalid+Scope%3A+public&state=%7B%22challenge%22%3A%222ZmK6R5F05d%252F060TkCqj8SjPLjc%253D%22%2C%220_auth_logger_id%22%3A%223C79F2C8-61B9-470E-AE1B-E1C68435DB83%22%2C%22com.facebook.sdk_client_state%22%3Atrue%2C%223_method%22%3A%22sfvc_auth%22%7D&e2e=%7B%22init%22%3A145973.000512302%7D#_=_

###### App : 


Optional(com.apple.SafariViewService)
nil

###### err:

Optional(Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=100, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Invalid Scope: public, com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0})

IDE:xcode 7 …

facebook facebook-graph-api ios parse-platform swift

60
推荐指数
3
解决办法
5万
查看次数

检查计时器是否正在运行

我一直在尝试用计时器重新填充游戏生活,但是每当我离开视图并返回时,计时器就会重复并变得更快。我试图用Timer?.isValid函数来解决这个问题,只在定时器无效时运行它,所以它永远不会重复,但它似乎无法检查if 语句中的定时器是否无效

这是我到目前为止一直使用的 if 语句:

if (myTimer?.isValid){
} else{
//start timer
}
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激,谢谢。

xcode nstimer ios swift swift3

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

iOS 应用程序 Spotlight 搜索不会出现在应用程序上

在搜索一些关键字后,我需要在聚光灯搜索中显示我的应用程序。该关键词之一是“预订”。使用 CoreSpotlight,我设法让它出现在“应用程序框”本身上,但不在结果中的“应用程序”框中。

正如您所看到的,Booking.com、AccorHotels 和 OpenTable 出现在“应用程序”框中,但我的应用程序却没有出现。我需要做什么才能出现在“应用程序”框中?一些关键词出现在“热门”上。

在此输入图像描述

iphone ios swift corespotlight

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

从选项卡栏控制器以模态方式呈现视图控制器

我想用相机构建一个视图。就像 Instagram 一样,中间有一个按钮,用户可以单击该按钮,然后相机视图就会显示出来。我实现了 的代码TabViewController,但AppDelegate没有任何反应,没有动画或新的演示ViewController

这是我的 AppDelegate:

import UIKit


class AppDelegate: UIResponder, UIApplicationDelegate, UITabBarControllerDelegate {
    var window: UIWindow?
    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: ViewController) -> Bool {
    if viewController is ViewController {
        let storyboard = UIStoryboard(name: "Main.storyboard", bundle: nil)
        if let controller = storyboard.instantiateViewController(withIdentifier: "cameraVC") as? ViewController {
            controller.modalPresentationStyle = .fullScreen
            tabBarController.present(controller, animated: true, completion: nil)
        }
        return false
    }
    return true
}
Run Code Online (Sandbox Code Playgroud)

这是我的故事板:

主故事板

有任何想法吗?

uitabbarcontroller ios swift

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

将远程图像加载到 Tableview 单元格中

我正在从服务中获取图像到表格视图单元格中。我有图像 URL,我可以cellForRowAtIndexPathlayoutSubViews表格视图单元格的方法中或在 方法中获取图像。哪个是获取远程数据最有效的地方

cellForRowAtIndexPath方法

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell =  self.tableView.dequeueReusableCell(withIdentifier: "custom") as! MovieViewCell
    cell.title =  searchResultMovies[indexPath.row].title
    cell.movieImage = searchResultMovies[indexPath.row].poster
    return cell
}
Run Code Online (Sandbox Code Playgroud)

layoutSubViews方法

override func layoutSubviews() {
    super.layoutSubviews()
    if let title = self.title{
        titleLabel.text = title
    }
    if let movieImage = self.movieImage {
        movieImageView.loadImageFromString(imageString: movieImage)
    }
}
Run Code Online (Sandbox Code Playgroud)

如果您注意到上面的代码,您可以看到我正在loadImageFromString从内部调用,layoutsubviews也可以在 cellForRowAtIndexPath. 哪个是更好的地方,为什么?

uitableview uikit ios swift

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

如何获取我的 iOS 应用程序的本地化语言?

我想添加一个功能来更改应用程序内的应用程序语言(独立于 iPhone 语言)。

为了显示可用的语言,我想获取支持的本地化语言列表并使其动态化,而不是对它们进行硬编码。然后,每次我添加新的本地化语言时,它都会自动添加到可用语言列表中。

有什么办法可以做到这一点吗?

localization ios swift

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