在 iOS 12 中,UIApplicationDelegate 协议定义:
- (BOOL) application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
Run Code Online (Sandbox Code Playgroud)
而在以前的 iOS 版本中,这是定义的:
- (BOOL) application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler
Run Code Online (Sandbox Code Playgroud)
这些定义的不同之处在于restoreHandler 的参数类型。因此,在 Xcode 10 中,我们现在收到警告:
'application:continueUserActivity:restorationHandler:' 实现中参数类型冲突:'void (^ _Nonnull __strong)(NSArray> * _Nullable __strong)' 与 'void (^__strong _Nonnull)(NSArray *__strong)'
我仍在致力于可能在 iOS 12 之前发布的更新,但我也在为支持 iOS 12 奠定基础。我不确定如何跨多个 iOS 版本处理不同的参数类型。
通常在一个方法中,我会使用类似 @available 的东西来根据运行时检测到的 iOS 版本来分支代码,但在这种情况下,我不知道最佳实践是什么。我当然不想为此而烦恼!我是否应该避免更改任何内容并接受警告,直到 Xcode 10 结束测试版并且我要提交 iOS 12 版本?那么它会在运行时向后兼容较低的 iOS 版本吗?
感谢您的任何帮助!
在开发 AR 应用程序时,一旦跟踪图像并放置 3D 模型,我需要将对象放置在 ARImageAnchor 上,那么它不应该随着图像锚点移动,它应该只跟随 iPhone 上的相机角度和给定的锚点距离。
尝试了很多代码。
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
let node = SCNNode()
if let imageAnchor = anchor as? ARImageAnchor {
self.mainNode.simdTransform = anchor.transform
self.sceneView.scene.rootNode.addChildNode(self.mainNode)
}
Run Code Online (Sandbox Code Playgroud)
另一种尝试:
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
let node = SCNNode()
if let imageAnchor = anchor as? ARImageAnchor {
guard let pointOfView = self.sceneView.pointOfView else { return }
let transform = pointOfView.transform
self.mainNode.transform = transform
self.sceneView.scene.rootNode.addChildNode(self.mainNode)
Run Code Online (Sandbox Code Playgroud)
}
func renderer(_ …Run Code Online (Sandbox Code Playgroud) 我想实现下载功能,可以用百分比显示下载任务的完成状态。我能够做到这一点,但问题是当应用程序移至后台并返回前台时,didWriteData未在iOS12. 谁能帮帮我吗?这是我的代码
protocol DownloadDelagate {
func downloadingProgress(value:Float)
func downloadCompleted(identifier: Int,url: URL)
}
class DownloadManager : NSObject, URLSessionDelegate, URLSessionDownloadDelegate {
static var shared = DownloadManager()
var delegate: DownloadDelagate?
var backgroundSessionCompletionHandler: (() -> Void)?
var session : URLSession {
get {
let config = URLSessionConfiguration.background(withIdentifier: "\(Bundle.main.bundleIdentifier!).background")
config.isDiscretionary = true
config.sessionSendsLaunchEvents = true
return URLSession(configuration: config, delegate: self, delegateQueue: OperationQueue())
}
}
private override init() {
}
func urlSessionDidFinishEvents(forBackgroundURLSession session: URLSession) {
DispatchQueue.main.async {
if let completionHandler = self.backgroundSessionCompletionHandler …Run Code Online (Sandbox Code Playgroud) 我的视图只有 2 个文本字段,用于用户名和密码。相应地指定内容类型。我想使用电话号码作为用户名,所以我选择“数字键盘”作为用户名字段的键盘类型。
问题是当我在 iOS 12 上运行它时,当第一次选择用户名字段时,自动填充控件不会出现在键盘上方。如果然后选择密码字段,它就会出现。然后我可以再次选择用户名字段,自动填充控制仍然存在并且这次可用。
如果我将用户名键盘类型更改为默认值,问题就会消失。
在 iOS 11 中不存在此问题。
有谁知道为什么会这样?
再会,
我无法复制崩溃,但我的几个在线用户遇到了崩溃。从 crashlytics 下载的崩溃报告如下。有人可以帮忙吗?它发生在 iOS12 上的用户身上。
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x220ee4ec4 __exceptionPreprocess
1 libobjc.A.dylib 0x2200b5a40 objc_exception_throw
2 CoreFoundation 0x220dfab3c +[_CFXNotificationTokenRegistration keyCallbacks]
3 Foundation 0x2218e91d0 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4 UIKitCore 0x24d55ed28 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:]
5 UIKitCore 0x24d562e14 -[UICollectionView _updateVisibleCellsNow:]
6 UIKitCore 0x24d567eb4 -[UICollectionView layoutSubviews]
7 UIKitCore 0x24e13b96c -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
8 QuartzCore 0x2254e1b74 -[CALayer layoutSublayers]
9 QuartzCore 0x2254e6b2c CA::Layer::layout_if_needed(CA::Transaction*)
10 UIKitCore 0x24e126e58 -[UIView(Hierarchy) layoutBelowIfNeeded]
11 UIKitCore 0x24e12da08 +[UIView(Animation) performWithoutAnimation:]
12 UIKitCore 0x24debd174 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:]
13 UIKitCore 0x24debd4bc -[UITableView _createPreparedCellForGlobalRow:willDisplay:]
14 UIKitCore 0x24de88b94 -[UITableView …Run Code Online (Sandbox Code Playgroud) 出于某种原因,iOS 12 Safari 中的密码输入显示大点。我希望它们看起来像在 Chrome 中一样。有没有一种已知的方法可以使用 CSS 来设置这些输入的样式?
<input type="password" name="pass" />
Run Code Online (Sandbox Code Playgroud)
这是它在 iOS 12 Safari 中的外观:
这是它在 Chrome 中的外观:
我遇到一个问题,.builtInDualCamera当isFilteringEnabled = true
这是我的代码:
fileprivate let session = AVCaptureSession()
fileprivate let meta = AVCaptureMetadataOutput()
fileprivate let video = AVCaptureVideoDataOutput()
fileprivate let depth = AVCaptureDepthDataOutput()
fileprivate let camera: AVCaptureDevice
fileprivate let input: AVCaptureDeviceInput
fileprivate let synchronizer: AVCaptureDataOutputSynchronizer
init(delegate: CaptureSessionDelegate?) throws {
self.delegate = delegate
session.sessionPreset = .vga640x480
// Setup Camera Input
let discovery = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDualCamera], mediaType: .video, position: .unspecified)
if let device = discovery.devices.first {
camera = device
} else {
throw SessionError.CameraNotAvailable("Unable to load camera")
} …Run Code Online (Sandbox Code Playgroud) 我正在使用本教程“iOS 12 密码工具:提高用户安全性和体验”为我的 iOS 应用程序实现自动填充,一切正常,但当我第一次登录时,iOS 没有通过 UIAlert 提示我保存密码。我想问一下如何触发 UIAlert 提示用户第一次将密码保存到钥匙串?
在我的响应式 Web 应用程序中,选择选项字体大小在 iPad 中自动调整大小,导致每个选项文本的字体大小不一致。(iOS12 iPad模拟器截图)
我做了研究并尝试了我遇到的一切:
-webkit-text-size-adjust: 100% (对身体)-webkit-appearance: none (选择)<option>s的<optgroup>但他们似乎都没有做任何事情。
<select>
<option value="None"></option>
<option value="1">Lorem ipsummmm sitamet consectetur</option>
<option value="2">Adipisc elitsed eiusmod</option>
</select>
Run Code Online (Sandbox Code Playgroud)
body {
-webkit-text-size-adjust: 100%;
}
select {
font-size: 16px;
}
Run Code Online (Sandbox Code Playgroud)
这是jsFiddle
我想要实现的是,无论选项文本长度如何,字体大小都是相同的大小,如果有可能的话。
由于第三方登录服务,我的应用程序被拒绝。所以我已经为 iOS 13 实现了 Sign in with Apple。问题是如何为 iOS 12 或更早版本提供向后兼容性。