我正在开发一个Apple Watch应用程序,它使用该openParentApplication:reply:
方法与其父应用程序进行通信.
父应用程序与Web服务通信,并通过调用包含数据的reply
方法将其获取的数据发送回监视扩展NSDictionary
.
当父应用程序在前台或后台打开时,该应用程序可以正常运行.但是,如果我打开父应用程序,然后使用任务切换器终止它,则第一次监视扩展程序调用时openParentApplication:replyInfo:
,会收到以下错误,参数replyInfo
以nil结尾.
UIApplicationDelegate in the iPhone App never called reply()
但是openParentApplication:replyInfo:
,在获得适当的响应之后,扩展所做的每一次调用.
我查了一下,发现手表扩展第一次拨打电话时,handleWatchKitExtensionRequest:reply:
永远不会在父应用上调用.
可能的原因是什么?
handleWatchKitExtensionRequest:reply:
正如文档中所建议的那样,我正在后台任务中执行所有操作.这是我的一些代码:来自我的扩展程序的代码:
NSDictionary *params = @{@"requestCode": @(RequestGetLoggedIn)};
[WKInterfaceController openParentApplication:params reply:^(NSDictionary *replyInfo, NSError *error) {
// Do something with the result
}];
Run Code Online (Sandbox Code Playgroud)
来自父应用的代码:
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
self.backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTask];
}];
NSNumber* requestCode = userInfo[@"requestCode"];
// Perform some request and then call …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建从用户相册中选择的视频的缩小版本。输出的最大尺寸为 720p。因此,在检索视频时,我使用.mediumQualityFormat
为deliveryMode
。如果用户设备中不存在原始视频或其中等质量版本,这会导致 iOS 从 iCloud 检索 720p 视频。
let videoRequestOptions = PHVideoRequestOptions()\nvideoRequestOptions.deliveryMode = .mediumQualityFormat\nvideoRequestOptions.isNetworkAccessAllowed = true\n\nPHImageManager.default().requestAVAsset(forVideo: asset, options: videoRequestOptions) { (asset, audioMix, info) in\n // Proceess the asset\n}\n
Run Code Online (Sandbox Code Playgroud)\n问题是,当我用来AVAssetExportSession
创建资产的缩小版本时,如果资产是中等变体而不是原始版本,则导出过程会立即失败并出现以下错误:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-17507), NSLocalizedDescription=\xc4\xb0\xc5\x9flem tamamlanamad\xc4\xb1, NSUnderlyingError=0x283bbcf60 {Error Domain=NSOSStatusErrorDomain Code=-17507 "(null)"}}\n
Run Code Online (Sandbox Code Playgroud)\n我在任何地方都找不到有关此错误含义的任何内容。
\n当我将deliveryMode
属性设置为.auto
或时.highQualityFormat
,一切正常。
当我检查资产 URL 时,我注意到从 iCloud 检索视频时,其文件名有一个“.medium”后缀,如下例所示:
\nfile:///var/mobile/Media/PhotoData/Metadata/PhotoData/CPLAssets/group338/191B2348-5E19-4A8E-B15C-A843F9F7B5A3.medium.MP4
奇怪的是,如果我将FileManager …
我有一个大型 SwiftUI 视图,其中包含底部菜单和其上方的一些小型 UI 组件。我想将此视图覆盖在现有实例之上UIViewController
,因此使用UIHostingController
.
我遇到的问题是,尽管 SwiftUI 视图的背景和透明视图的背景都不同,但 SwiftUI 视图的透明区域不会转发触摸UIHostingController
。
由于我无法替换 所使用的视图子类UIHostingController
,因此我无法扰乱其命中测试机制以使其手动转发触摸。
有办法做到这一点吗?现在看来是不可能的。
在我尝试的所有WatchOS应用程序中(除了Apple自己的应用程序),包括我正在开发的那些应用程序,我注意到,一旦我从屏幕的左边缘滑动回到上一个,我有时候没有通过点击屏幕上的任何一个按钮,可以更长时间进入任何其他屏幕.
这似乎是一个严重的错误,一旦您尝试通过在主界面控制器中滑动几次,然后点击界面上推动另一个屏幕的任何一个按钮,它就会变得更加突出.只有再次向后滑动时,它才会推动另一个屏幕,并带有一个错误的动画.这真的很奇怪.
有没有办法禁用该手势?
还有,有人向Apple报告过此事吗?