显然,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
这是我在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)
但是,我现在看不出有什么变化,或者现在是什么使它变得如此必要.
就我所知,唯一改变的是观察的语法,但我不明白为什么这导致我的代码停止工作.
我不完全理解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之间有什么区别?
使用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) 在旧版本的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中第一个代码块的功能?
当您使用故事板引用将segue执行回故事板时,它会加载该故事板的初始视图控制器.
我需要从另一个故事板中找到一个不是我初始视图控制器的视图控制器.
你是如何做到这一点的?