我正在使用SafariViewController显示网页,而不是默认的"完成"按钮,我从我的应用程序推送NavigationController以保留我的导航堆栈和后退箭头.但是,我需要隐藏默认的完成按钮和搜索栏SafariViewController.这可能吗?请参阅下面的代码和屏幕截图...
let svc = SFSafariViewController(URL: pinterestSafariURL)
navigationController?.pushViewController(svc, animated: true)
Run Code Online (Sandbox Code Playgroud)
注意:链接到这个问题,但答案是黑客,而我正在寻找使用SafariViewController API的解决方案:SFSafariViewController:隐藏导航栏
在Facebook的文档中,他们引用了wit.ai Bot Engine,但我在网上找不到它解释如何将你在Wit中构建的故事与你的Facebook Messenger App连接起来?
我正在为iOS 10设置一个需要登录社交网络的iMessage应用程序.在传统的iOS应用程序中,我们通常在AppDelegate中配置带有app id的共享实例...我还需要处理回调URL:传统上放置在AppDelegate中的2个方法(下面).
使用iMessage app/extension,没有AppDelegate.我在哪里可以放置此代码?我能够在应用程序ID配置willBecomeActive上MessagesViewController并没有得到一个实例回来了,但我也把这些方法MessagesViewController与破发点,他们从来不被称为,我相信这是防止我的成功日志中,任何帮助深表感谢!
更新:我最大的问题,甚至在弄清楚如何处理callBack之前就是如何没有openURL方法可用,有一些关于扩展的方法,但我没有成功提出任何建议的解决方案: openURL不起作用在行动扩展中
我看到它要么(1)找到一种方法在我的iMessage扩展中调用openURL,这样我就可以让SDK处理OAuth(2)创建我自己的webview,推送到网站,登录用户,存储令牌和segue回到我的应用程序(似乎没必要)或(3)创建一个iPhone应用程序,只是为了登录(即iMessage扩展打开的父应用程序和登录),再次似乎没有必要).当然,这在iMessage扩展中会很常见吗?
func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool {
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
}
Run Code Online (Sandbox Code Playgroud) 我正在测试我的代码开始HKWorkoutSession收集样本和结束然后使用旧的HKWorkoutConfigurationAPI(而不是新的HKWorkoutBuilderAPI)保存锻炼....我的理解是,以前的API应该仍然有用.
然而,当在手表模拟器中测试,使用Xcode 10 Beta 4和5开始和停止锻炼时,我注意到我能够开始锻炼并查询样本,但是当我打电话时,healthStore.stop有5或6秒的延迟,直到锻炼结束?
// Create workout configuration
let workoutConfiguration = HKWorkoutConfiguration()
workoutConfiguration.activityType = .running
workoutConfiguration.locationType = .outdoor
do {
workoutSession = try HKWorkoutSession(configuration: workoutConfiguration)
workoutSession?.delegate = self
} catch {
fatalError(error.localizedDescription)
}
func start(_ workoutSession: HKWorkoutSession) {
healthStore.start(workoutSession)
}
func end(_ workoutSession: HKWorkoutSession) {
healthStore.end(workoutSession)
}
Run Code Online (Sandbox Code Playgroud)
更新9/20/18:我提交了一个雷达,它被标记为dup ....从Xcode 10 GM版本开始,这个bug仍然存在.确认这不会发生在设备上,只有模拟器.
我们如何将锁屏小部件添加到现有的小部件包中并仍然支持 iOS 15?:thinking_face: 例如,这不会编译
struct SecondExtraBundle: WidgetBundle {
@WidgetBundleBuilder
var body: some Widget {
DailyHeartRatesWidget()
if #available(iOSApplicationExtension 16.0, *) {
LockScreenRecoveryScoreWidget()//Requires iOS 16?
} else {
// Fallback on earlier versions
}
}
}
Run Code Online (Sandbox Code Playgroud) 我想在UIWebView例如显示iTunes链接https://itunes.apple.com/us/album/burn-that-broken-bed/id1120162623?i=1120163074&uo=4
问题是这些链接在浏览器中加载时会自动重定向到iTunes应用程序,而不是UIWebView像我正在尝试的那样显示内容.
我怎样才能(1)阻止重定向以便显示内容(2)是否有另一种方法来形成不会重定向的iTunes链接?(3)任何其他选择?
通过 Cocoapods 和桥接头使用 Pinterest 的 iOS SDK,在我的应用程序中运行良好。
在我的项目中创建了新的目标 -> 操作扩展。尝试在链接框架和库中链接 PDK 框架,尝试在扩展中添加单独的桥接头文件,但 Xcode 崩溃无法找到它......关于如何导入它的任何想法?
播客文件:
platform :ios, '9.0'
pod "PinterestSDK", :git => "git@github.com:pinterest/ios-pdk.git"
pod "PINRemoteImage"
pod "GBDeviceInfo"
pod 'FBSDKCoreKit'
xcodeproj '/Users/garysabo/Dropbox/Xcode Projects/pinFixer2/pinFixer2.xcodeproj'
Run Code Online (Sandbox Code Playgroud)
桥接头:
#import "PinterestSDK.h"
#import "PDKPin.h"
#import "PDKBoard.h"
#import "PDKImageInfo.h"
#import "PDKResponseObject.h"
#import "PDKClient.h"
#import "PDKModelObject.h"
#import "PDKUser.h"
Run Code Online (Sandbox Code Playgroud) 我的Xcode项目中有一个XML文件,我想先把它保存到磁盘上,其次我怎么知道我是否成功保存了它?这是正确的方法吗?使用模拟器我导航到iOS 11中的新"文件"文件夹,我看不到它,但我不确定它是否应该存在?
guard let path = Bundle.main.url(forResource: "sample", withExtension: "xml") else {print("NO URL"); return}
let sample = try? Data(contentsOf: path)
print("sample XML = \(String(describing: sample?.debugDescription))")
//put xml file on the device
let filename = getDocumentsDirectory().appendingPathComponent("sample.xml")
do {
try sample?.write(to: filename)
} catch {
print("ERROR")
}
Run Code Online (Sandbox Code Playgroud)
更新以包括我检查文件是否存在:
//check if file exists
let checkPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
let url = URL(fileURLWithPath: checkPath)
let filePath = url.appendingPathComponent("sample.xml").path
let fileManager = FileManager.default
if fileManager.fileExists(atPath: filePath) {
print("FILE AVAILABLE")
} else { …Run Code Online (Sandbox Code Playgroud) 编辑以添加我的更新代码,该代码是我根据 WWDC 2016 的充分利用 Healthkit 演讲编写的,但除非我打开应用程序,否则我仍然无法获得新锻炼的打印声明。
将新的锻炼项目保存到 Apple Watch 后,我尝试在 iPhone 上进行观察。下面是我正在运行的代码didFinishLaunching。为了测试它,我在我的 iPhone 应用程序上运行 Xcode...构建并运行,然后导航回主屏幕。然后在我的手表上开始并保存锻炼,但是我的打印语句没有在控制台中打印。我缺少什么?
func startObservingNewWorkouts() {
let sampleType = HKObjectType.workoutType()
//1. Enable background delivery for workouts
self.healthStore.enableBackgroundDelivery(for: sampleType, frequency: .immediate) { (success, error) in
if let unwrappedError = error {
print("could not enable background delivery: \(unwrappedError)")
}
if success {
print("background delivery enabled")
}
}
//2. open observer query
let query = HKObserverQuery(sampleType: sampleType, predicate: nil) { (query, completionHandler, error) in
self.updateWorkouts() {
completionHandler()
}
} …Run Code Online (Sandbox Code Playgroud) 下面的代码在 WatchOS 7 和 8.0 中运行良好,但现在在 8.1 中,点击该行将导航到目的地,但随后立即导航回根视图。
我提交了反馈#FB9727188,并包含以下内容来演示该问题。
struct ContentView: View {
@State var tabIndex:Int = 0
var body: some View {
TabView(selection: $tabIndex) {
ListView()
.tabItem { Group{
Text("List")
}}.tag(0)
.padding(.bottom, 1.0)
Text("Second View")
.tabItem { Group{
Text("Second")
}}.tag(1)
.padding(.bottom, 1.0)
Text("Third View")
.tabItem { Group{
Text("ThirdView")
}}.tag(2)
}
}
}
struct ListView: View {
var body: some View {
List {
ForEach((1...10).reversed(), id: \.self) {_ in
NavigationLink(destination: Text("test")) {
Text("Tap Me but we'll just be back here") …Run Code Online (Sandbox Code Playgroud)