试图在模拟器上运行构建,我收到此错误:
打开"com.companyname.appname"的请求失败.
服务委托(SBMainWorkspace)拒绝了该请求的原因:安全性(启动应用程序以进行调试所需的"权利"com.apple.frontboard.debugapplications").
当使用GM时Xcode 8
,这不存在,但是当我从mac app store再次下载它时就开始了.谷歌也没有帮助苹果开发者论坛.
任何帮助或建议?
我的按钮的背景区域未检测到用户交互。与所述按钮交互的唯一方法是点击按钮的文本/标签区域。如何使整个 Button 可点击?
struct ScheduleEditorButtonSwiftUIView: View {
@Binding var buttonTagForAction : ScheduleButtonType
@Binding var buttonTitle : String
@Binding var buttonBackgroundColor : Color
let buttonCornerRadius = CGFloat(12)
var body: some View {
Button(buttonTitle) {
buttonActionForTag(self.buttonTagForAction)
}.frame(minWidth: (UIScreen.main.bounds.size.width / 2) - 25, maxWidth: .infinity, minHeight: 44)
.buttonStyle(DefaultButtonStyle())
.lineLimit(2)
.multilineTextAlignment(.center)
.font(Font.subheadline.weight(.bold))
.foregroundColor(Color.white)
.border(Color("AppHighlightedColour"), width: 2)
.background(buttonBackgroundColor).opacity(0.8)
.tag(self.buttonTagForAction)
.padding([.leading,.trailing], 5)
.cornerRadius(buttonCornerRadius)
}
}
Run Code Online (Sandbox Code Playgroud) 创建Today小部件,我UserDefaults(suiteName:)
用来保存一些数据.在我正在使用的主要应用程序中UserDefaults.standard()
.这是扩展无法读取(或可以吗?),这就是我使用suiteName:
构造函数的原因.
用户UserDefaults.standard()
在主应用中持久保存的数据需要在扩展中可用.
在这个时候,我坚持两者,以便可以共享价值观
UserDefaults.standard().set:...forKey:...
UserDefaults(suiteName:...)().set:...forKey:...
...
Run Code Online (Sandbox Code Playgroud)
问题是我应该UserDefaults.standard()
放在一起,只是UserDefaults(suiteName:)
在我的应用程序中使用,或者这是不好的做法,如果是这样,为什么?
编辑:我正在使用App组容器.为了澄清我要问我应该在我的项目中用suiteName替换standard()吗?
在iOS 10和xcode 8中,当我尝试登录谷歌服务时,我收到"钥匙串错误"
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!){
if error != nil {
print("\(error!.localizedDescription)")
}
}
Run Code Online (Sandbox Code Playgroud)
在SO上提供和接受的解决方案是直接从模拟器而不是通过Xcode运行应用程序.我试过这个并没有成功因此在这里发布这个问题,希望有人有更新的解决方案或经验.
我试图在Apple手表应用程序上并排放置2个WKInterfaceButton项目.我有一个WKInterfaceGroup,我将其布局设置为水平.这允许我将按钮彼此相邻放置.问题是让它们完全并排放置并填充屏幕宽度并自动调节,无论手表大小(38或42mm).目前我将一个左右对齐.然后调整宽度我必须手动调整宽度,直到它看起来正确.这似乎有点太难编码,因为它不允许任何未来的手表屏幕尺寸变化.
我需要的是一种将WKInterface元素(在本例中为按钮)设置为手表可用尺寸的一半的方法.在普通的应用程序中,您可以使用
uiElementWidth = [UIScreen mainScreen].bounds.size.width/2
Run Code Online (Sandbox Code Playgroud)
WatchKit中有等价物吗?
在我的AppDelegate中使用谷歌SignIn我有
func application(application: UIApplication,
openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
return GIDSignIn.sharedInstance().handleURL(url,
sourceApplication: sourceApplication,
annotation: annotation)
}
Run Code Online (Sandbox Code Playgroud)
但是从iOS 9开始,该功能已被弃用
application:openURL:options:
Run Code Online (Sandbox Code Playgroud)
如何回归
GIDSignIn.sharedInstance().handleURL(url,sourceApplication:sourceApplication,annotation:annotation)
使用iOS 9的新功能?
使用iOS11 Swift和PDFKit.我有一份约300页的pdf文件.每页可能有100个字符.整个文件大小约为4mb.当我将文件加载到PDFView时,应用程序内存增加到30mb +.当我滑到下一页时,它再增加30mb +.如果I.滑动到pdf的末尾,我在Xcode中遇到了内存崩溃.那么当该页面不再可见时,如何从内存中清除PDFPage?
码
func loadPDFDocument(){
let documentURL = Bundle.main.url(forResource: "TestPDF", withExtension: "pdf")!
if let document = PDFDocument(url: documentURL) {
for page in 1...document.pageCount {
DispatchQueue.global().async {
print(document.page(at: page)!.string!)
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 当我用xCode运行我的应用程序时,所有加载并运行正常.当我加载仪器并使用活动监视器或分配的分析模板按记录时,它会加载并运行正常.但是,如果我使用Zombies或Leaks,应用程序会立即崩溃.我甚至都看不到它.然后我访问xcode中的崩溃日志,虽然崩溃的原因是异常类型:EXC_BAD_ACCESS(SIGSEGV)
由于每个报告都不同,因此几乎不可能调试原因.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000010
VM Region Info: 0x10 is not in any region. Bytes before following region: 4297687024
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 0000000100298000-0000000100388000 [ 960K] r-x/r-x SM=COW ...p/MyApp
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 …
Run Code Online (Sandbox Code Playgroud) YouTube 允许用户名和频道名称。它们可以彼此不同。youtube API 允许我通过用户名进行搜索,但我看不到在哪里或如何通过频道名称进行搜索。这是视频下方显示的频道名称。有人告诉我如何通过频道名称/标题而不是用户名进行搜索吗?谢谢
我正在尝试从 URL 下载 PDF。
private func downloadSessionWithFileURL(_ url: URL){
var request = URLRequest(url: url)
request.addValue("gzip, deflate", forHTTPHeaderField: "Accept-Encoding")
let sessionConfig = URLSessionConfiguration.default
let session = URLSession(configuration: sessionConfig, delegate: self, delegateQueue: nil)
session.downloadTask(with: request).resume()
}
Run Code Online (Sandbox Code Playgroud)
这调用了它的委托方法
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
if challenge.previousFailureCount > 0 {
completionHandler(Foundation.URLSession.AuthChallengeDisposition.cancelAuthenticationChallenge, nil)
}
if let serverTrust = challenge.protectionSpace.serverTrust {
completionHandler(Foundation.URLSession.AuthChallengeDisposition.useCredential, URLCredential(trust: serverTrust))
} else {
print("unknown state. error: \(String(describing: challenge.error))")
}
}
Run Code Online (Sandbox Code Playgroud)
URLAuthenticationChallenges 保护空间始终是 serverTrust。当尝试访问 PDF …
gidsignin ×2
swift ×2
xcode ×2
apple-watch ×1
ios10 ×1
ios9 ×1
keychain ×1
pdfkit ×1
swift4 ×1
swiftui ×1
urlauthenticationchallenges ×1
userdefaults ×1
watchkit ×1
xcode10 ×1
xcode8 ×1
xcode8-beta4 ×1
youtube ×1