小编use*_*041的帖子

当应用程序在前景Swift 3时获取本地通知

显然,ios10现在可以实现这一点:

optional func userNotificationCenter(_ center: UNUserNotificationCenter, 
                 willPresent notification: UNNotification, 
  withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void)
Run Code Online (Sandbox Code Playgroud)

这个答案基本上说明了做这件事所需的工具:

当您的应用程序处于打开状态且位于前台时显示库存iOS通知横幅?

我只是不太了解如何将它们放在一起.

我不知道这有多重要,但我无法保留可选的func,xcode要我将其切换为私有.

我正试图展示徽章,文档提供

static var badge: UNNotificationPresentationOptions { get }
Run Code Online (Sandbox Code Playgroud)

这里很少丢失.

然后我假设我想要排除某个视图控制器获取这些徽章并且我没有使用导航控制器这个代码我发现它会起作用吗?:var窗口:UIWindow?

if let viewControllers = window?.rootViewController?.childViewControllers {
for viewController in viewControllers {
    if viewController.isKindOfClass(MyViewControllerClass) {
        print("Found it!!!")
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

ios uilocalnotification swift swift3 unusernotificationcenter

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

更新到Swift 3后,类型"Any"没有下标成员

这是我在Swift中的代码:

currentUserFirebaseReference.observeSingleEvent(of: .value, with: { (snapshot: FIRDataSnapshot) in
        let UID = snapshot.key
        let pictureURL = snapshot.value!["pictureURL"] as! String
        let name = snapshot.value!["displayname"] as! String
        let currentUser = Person(name: name, bio: "", UID: UID, pictureURL: pictureURL)
        self.currentUserInfo = currentUser
            })
Run Code Online (Sandbox Code Playgroud)

我刚刚更新到Xcode 8/Swift 3,这似乎导致了以下错误消息:

"输入'任意'没有下标成员"

我在我的代码中的许多地方调用snapshot.value!["插入一些东西"],我收到此错误,我无法运行我的代码.

以下代码有效:

let pic = (snapshot.value as? NSDictionary)?["pictureURL"] as? String ?? ""
Run Code Online (Sandbox Code Playgroud)

但是,我现在看不出有什么变化,或者现在是什么使它变得如此必要.

就我所知,唯一改变的是观察的语法,但我不明白为什么这导致我的代码停止工作.

ios firebase swift firebase-realtime-database

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

春萌到链接动画?

我不完全理解Meng To's Spring的文档.

https://github.com/MengTo/Spring

给出的可用功能是

animate()
animateNext { ... }
animateTo()
animateToNext { ... }
Run Code Online (Sandbox Code Playgroud)

给出的链接示例是:

layer.y = -50
animateToNext {
  layer.animation = "fall"
  layer.animateTo()
}
Run Code Online (Sandbox Code Playgroud)

我没有看到实际解释这些功能所做的任何地方.也许它超级直接,我只是想念它..

如果我想将3个动画链接在一起,让我们用这个来表示layer.animation ="fall",那个例子会是什么样子,animateNext,animateTo和animateToNext之间有什么区别?

ios swift

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

(setValue :)无法在pictureURL中存储_SwiftValue类型的对象.只能存储NSNumber,NSString,NSDictionary和NSArray类型的对象

使用Swift 3了解firebase有一些问题.

我重新让我的观察者看起来像这样:

  currentUserFirebaseReference.observeSingleEvent(of: .value, with: { (snapshot: FIRDataSnapshot) in
            let UID = snapshot.key

   let dict = snapshot.value as! Dictionary<String,AnyObject>
   let pictureURL = dict["pictureURL"] as! String
Run Code Online (Sandbox Code Playgroud)

我曾经只是这样做

observation..... in {

let picture = snapshot.value!["pictureURL"]
Run Code Online (Sandbox Code Playgroud)

但现在我想你必须明确告诉Firebase你正在处理一个字典吗?

当我试图设置一个值时,我的问题就来了.

我将上面的pictureURL添加到Person类中,后来我正在做:

 let picURL = self.currentUserInfo.pictureURL // The picture from before

  let info = ["pictureURL" : picURL, ....morestuff] as [String : Any] // Swift conversion added the String:Any bit. Assume this is correct?

ref.setValue(info)
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Terminating app due to uncaught exception 'InvalidFirebaseData', reason: '(setValue:) Cannot …
Run Code Online (Sandbox Code Playgroud)

ios firebase swift firebase-realtime-database swift3

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

使用Swift 3检查用户身份验证错误代码

在旧版本的Swift中,可以使用以下代码检查用户身份验证错误:

 if (error != nil) {
    // an error occurred while attempting login
    if let errorCode = FAuthenticationError(rawValue: error.code) {
        switch (errorCode) {
        case .UserDoesNotExist:
            println("Handle invalid user")
        case .InvalidEmail:
            println("Handle invalid email")
        case .InvalidPassword:
            println("Handle invalid password")
        default:
            println("Handle default situation")
        }
    }
} 
Run Code Online (Sandbox Code Playgroud)

FAuthenticationError似乎不再存在,文档使它看起来像被替换FIRAuthErrorNameKey.

放在FIRAuthErrorNameKey哪里FauthenticationError会导致错误:

cannot call nonfunctiontype String
Run Code Online (Sandbox Code Playgroud)

以下是我正在查看的文档:https://firebase.google.com/docs/auth/ios/errors

任何想法如何实现Swift 3中第一个代码块的功能?

ios firebase swift firebase-authentication

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

JSQMessages键盘没有推高视图

当我在我的JSQMessagesViewController中输入一条消息时,当键盘出现时,视图没有被推高. 在此输入图像描述

我无法发送消息,我看不到正在输入的消息.

我甚至没有看到我的VC中的任何代码会导致这个/那会改变这个,所以我不知道从哪里开始查找或提供什么代码.我已经使用JSQMessages下载了示例,我觉得这只是在幕后内置功能.

有任何想法吗?

ios swift jsqmessagesviewcontroller

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

如何在不同的故事板中转换到特定的视图控制器?

当您使用故事板引用将segue执行回故事板时,它会加载该故事板的初始视图控制器.

我需要从另一个故事板中找到一个不是我初始视图控制器的视图控制器.

你是如何做到这一点的?

xcode storyboard ios swift

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