如何检查用户是否在ios 9或ios 10上启用了远程通知?
如果用户未允许或单击否我想切换询问是否要启用通知的消息.
我已经设置了一个协议,将一些信息发送回以前的VC.
我这样定义它:
protocol FilterViewControllerDelegate: class {
func didSearch(Parameters:[String: String]?)
}
Run Code Online (Sandbox Code Playgroud)
但使用时有什么区别:
protocol FilterViewControllerDelegate {
func didSearch(Parameters:[String: String]?)
}
Run Code Online (Sandbox Code Playgroud)
我什么时候应该使用: class协议?
我想知道tableview是否有任何内置函数来添加无限滚动/分页.
现在我的VC看起来像这样:
var data: JSON! = []
override func viewDidLoad() {
super.viewDidLoad()
//Init start height of cell
self.tableView.estimatedRowHeight = 122
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.delegate = self
self.tableView.dataSource = self
savedLoader.startAnimation()
//Load first page
loadSaved(1)
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("aCell") as! SavedTableViewCell
let info = data[indexPath.row]
cell.configureWithData(info)
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("WebSegue", sender: indexPath) …Run Code Online (Sandbox Code Playgroud) 我想知道如何检查用户是否将显示设置为缩放模式.
我试过这个:
public var isZoomed: Bool {
return UIScreen.main().scale < UIScreen.main().nativeScale
}
Run Code Online (Sandbox Code Playgroud)
并且:
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_5 (IS_IPHONE && ([[UIScreen mainScreen] bounds].size.height == 568.0) && ((IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale) || !IS_OS_8_OR_LATER))
#define IS_STANDARD_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale)
#define IS_ZOOMED_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0 && IS_OS_8_OR_LATER && [UIScreen …Run Code Online (Sandbox Code Playgroud) 当我要为第二个视图解雇我的segue时,我也会发送一些像这样的值:
if let aTime = ads[indexPath.row]["unix_t"].int {
toView.time = aTime
}
if let aTitle = ads[indexPath.row]["title"].string {
toView.title = aTitle
}
Run Code Online (Sandbox Code Playgroud)
在第二个VC我宣布变量如下:
var time: Int?
var title: String?
Run Code Online (Sandbox Code Playgroud)
这就是我解开值的方式:
if time != nil {
timeLabel.text = String(time!)
}
if title != nil {
titleLabel.text = title!
}
Run Code Online (Sandbox Code Playgroud)
这一切都有效我从来没有得到任何由未包装的varibles或nil值引起的错误.但有没有更简单的方法呢?
现在感觉我检查太多了
想知道是否有可能从Laravel对Firebase的用户进行身份验证?
我在我的webapp和ios应用程序后面使用laravel作为休息API.我想要做的是一旦用户登录我的api,我想将它们登录到firebase,因为我的聊天/通知将取决于firebase.
我已经使用这个lib来将我的模型同步到firebase:https://github.com/mpociot/laravel-firebase-sync
谢谢,
php laravel firebase firebase-authentication firebase-realtime-database
我想知道当前上下文和全屏之间的区别是什么?
当我在它们之间切换时,我看不到我的应用程序中的任何更改.所有的动画看起来都一样.
我正在使用Amazon S3为我的网络应用和iOS应用程序存储图像.
我想知道在获取图像时是否可以安全地对我的存储桶URL进行硬编码?因此,我不必再进行一次API调用来获取我的URL.
例如,在我的应用代码中对此进行硬编码:
https://s3.eu-central-1.amazonaws.com/mybucket/images/{some_var}
Run Code Online (Sandbox Code Playgroud) 我想知道如何正确检查uitextview是否为空.
现在我有一个验证功能来检查:
if let descText = myTextView.text {
if descText.isEmpty {
descErrorLabel.isHidden = false
} else {
descErrorLabel.isHidden = true
}
}
Run Code Online (Sandbox Code Playgroud)
这足以阻止用户发送空文本视图,或者我也必须检查空格,例如:
stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).isEmpty
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,用户可以使用电子邮件/密码验证/登录我的后端.现在我正在考虑实现触摸ID.
但我对使用触摸ID的登录流程感到困惑.
使用下面的代码,我可以轻松验证用户:
func authenticateUser() {
let context = LAContext()
var error: NSError?
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
let reason = "Identify yourself!"
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) {
[unowned self] success, authenticationError in
DispatchQueue.main.async {
if success {
self.runSecretCode()
} else {
let ac = UIAlertController(title: "Authentication failed", message: "Sorry!", preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "OK", style: .default))
self.present(ac, animated: true)
}
}
}
} else {
let ac = UIAlertController(title: "Touch ID not available", message: "Your device is not configured for Touch …Run Code Online (Sandbox Code Playgroud)