在纵向模式下的iPhone X上,如果将安全区域的底部约束设置为0,则最终会在屏幕底部留出额外的空间.你如何以编程方式获得这个额外填充的高度?
我设法手动确定这个填充的高度是34,这是我如何设法用iPhone X检测实现它:
Swift 4.0和Xcode 9.0
if UIDevice().userInterfaceIdiom == .phone
{
switch UIScreen.main.nativeBounds.height
{
case 2436: //iPhone X
self.keyboardInAppOffset.constant = -34.0
default:
self.keyboardInAppOffset.constant = 0
}
}
Run Code Online (Sandbox Code Playgroud)
有没有更清晰的方法来检测这个填充的高度?
我正在尝试为我的 Flutter 仅 Web 项目实现“使用 Apple 登录”。
我完全按照 FlutterFire 文档 ( https://firebase.flutter.dev/docs/auth/social#apple )中的 Web 实现说明进行操作。我还没有在 iOS 和 Android 上实现它。我已经在我的网络应用程序中成功实现了 Google 和 Facebook 登录。
当我打电话时:
import 'package:firebase_auth/firebase_auth.dart';
Future<UserCredential> signInWithApple() async {
// Create and configure an OAuthProvider for Sign In with Apple.
final provider = OAuthProvider("apple.com")
..addScope('email')
..addScope('name');
// Sign in the user with Firebase.
return await FirebaseAuth.instance.signInWithPopup(provider);
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误(并且我的 Chrome 测试窗口中没有出现使用 Apple 登录的弹出窗口):
FirebaseAuthException ([firebase_auth/unknown] An unknown error occurred: Unexpected null value.)
>
credential:null
email:null
phoneNumber:null
tenantId:null
Run Code Online (Sandbox Code Playgroud)
可能是什么问题呢 ?意外的空值可能是什么?如果是电子邮件值,为什么我至少没有使用苹果弹出窗口登录?
情况
我有一个函数,它使用DateComponentFormatter's 函数fun string(from: Date, to: Date)根据两个日期之间的时差返回一个格式化的字符串,它工作得很好。但是我想始终以英语返回这个格式化的字符串(当前根据设备的本地格式进行格式化)。
问题
你如何DateComponentFormatter像你可以用DateFormatter's做的那样设置's 本地?如果你不能,你将如何进行?
代码:
import Foundation
func returnRemainingTimeAsString(currentDate: Date, nextDate: Date)->String {
let dateComponentsFormatter = DateComponentsFormatter()
dateComponentsFormatter.unitsStyle = DateComponentsFormatter.UnitsStyle.full
dateComponentsFormatter.allowedUnits = [.day, .hour, .minute, .second]
dateComponentsFormatter.maximumUnitCount = 1
let differenceAsString = dateComponentsFormatter.string(from: currentDate, to: nextDate)!
return differenceAsString
}
let currentDate = Date()
let futureDate = currentDate.addingTimeInterval(3604)
returnRemainingTimeAsString(currentDate: currentDate, nextDate: futureDate)
// prints 1 hour (if devices local is English) or 1 hora (if …Run Code Online (Sandbox Code Playgroud) 斯威夫特 4 & >iOS 10.0
我想在特定日期和给定时间(比如下午 3 点)安排本地通知。我希望通知总是在下午 3 点发出,无论我在哪个时区(根据时区自动重新安排通知)。
以前,您可以调整UILocalNotifications“时区”来实现这一点,就像这篇 SO 帖子中完美解释的那样。但是,在>iOS 10.0,UILocalNotifications已弃用。
这是我的代码:
func scheduleNotification(title: String, message: String, atDate: Date){
let center = UNUserNotificationCenter.current()
// Create content
let content = UNMutableNotificationContent()
content.title = title
content.body = message
content.sound = UNNotificationSound.default()
// Create trigger
let calendar = Calendar(identifier: .gregorian)
let triggerDate = calendar.dateComponents([.year,.month,.day,.hour,.minute,.second,], from: atDate)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDate, repeats: false)
// Create identifier
let identifier = "\(UUID())"
// Create …Run Code Online (Sandbox Code Playgroud) 我的应用程序中有一个用于创建帐户的网络视图(我没有编写,也无法更改关联的网页)。
\n\n通常,单击任何按钮/链接都很容易,但这里我的“创建帐户”按钮的字符串在其标题中具有很棒的字体,使得记录器崩溃并且无法以编程方式调用该按钮。
\n\n这是它打印的内容app.webViews.allElementsBoundByIndex:
Element subtree:\n \xe2\x86\x92WebView, 0x1c03823c0, traits: 8589934592, {{0.0, 0.0}, {736.0, 414.0}}\n...\nLink, 0x1c0384100, traits: 8590065666, {{242.0, 357.0}, {252.0, 44.0}}, label: \'create account \xef\x84\x85\'\nRun Code Online (Sandbox Code Playgroud)\n\n正如你所看到的,很棒的字体变成了 \xef\x84\x85我无法检测到的字体,例如:
webViews.staticTexts["create account \xef\x84\x85"].tap()\nRun Code Online (Sandbox Code Playgroud)\n\n问题
\n\n