在我看来,我有三个按钮.在viewDidLoad()中设置cornerRadus之后:button.layer.cornerRadius = 20
我在日志中收到以下错误消息:
<Error>: CGContextSaveGState: invalid context 0x0.
If you want to see the backtrace, please set
CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Run Code Online (Sandbox Code Playgroud)
问题:
好的,我现在从消息中回溯了.这对我没有任何意义.一些帮助请...
Aug 7 14:27:00 <Error>: CGContextSaveGState: invalid context 0x0. Backtrace:
<-[UIStatusBarItemView updateContentsAndWidth]+33>
<-[UIStatusBarItemView initWithItem:data:actions:style:]+477>
<+[UIStatusBarItemView createViewForItem:withData:actions:foregroundStyle:]+134>
<-[UIStatusBarLayoutManager _createViewForItem:withData:actions:]+163>
<-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:]+36
<-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:]+92>
<-[UIStatusBarForegroundView _setStatusBarData:actions:animated:]+797>
<-[UIStatusBarForegroundView setStatusBarData:actions:animated:]+332>
<__51-[UIStatusBar _prepareToSetStyle:animation:forced:]_block_invoke+360>
<+[UIView(Animation) performWithoutAnimation:]+65>
<-[UIStatusBar _prepareToSetStyle:animation:forced:]+866>
<-[UIStatusBar _requestStyleAttributes:animationParameters:forced:]+391>
<-[UIStatusBar requestStyle:animationParameters:forced:]+437>
<-[UIStatusBar requestStyle:animated:forced:]+90>
<-[UIStatusBar _evaluateServerRegistration]+250>
<__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke+590>
<-[UIView(Hierarchy) _postMovedFromSuperview:]+544>
<-[UIView(Internal) _addSubview:positioned:relativeTo:]+1967>
<-[UIStatusBarWindow setStatusBar:]+288>
<-[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:]+340>
<-[UIApplication _runWithMainScene:transitionContext:completion:]+950>
<-[UIApplication workspaceDidEndTransaction:]+188>
<-[FBSSerialQueue …
Run Code Online (Sandbox Code Playgroud) 我已经阅读了3次文档,但我仍然不知道它的作用.有人可以ELI5(解释就像我五岁)吗?这是我使用它的方式:
fun main(args: Array<String>) {
val UserModel = UserModel()
val app = Javalin.create().port(7000).start()
with (app) {
get("/users") {
context -> context.json(UserModel)
}
}
}
Run Code Online (Sandbox Code Playgroud) 在使用UITableView时,有两种类型的方法,即数据源和委托仍然应该连接到同一父视图控制器类.
有没有办法在不同的类中定义委托和数据源?
为什么我们需要分离作为代表和数据源?
注意:此问题适用于UICollectionView和类似的对象
我正在尝试将我的iOS应用程序中的位置共享给WhatsApp,我希望它看起来像这样:
我正在做的是用以下代码发送vCard:
func vCardURL(from coordinate: CLLocationCoordinate2D, with name: String?) -> URL {
let vCardFileURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("Shared Location.loc.vcf")
let vCardString = [
"BEGIN:VCARD",
"VERSION:3.0",
//"PRODID:-//Apple Inc.//iPhone OS 10.3.2//EN",
"N:;My Location;;;",
"FN:My Location",
"item1.URL;type=pref:https://maps.apple.com/?ll=50.359890\\,12.934560&q=My%20Location&t=m",
"item1.X-ABLabel:map url",
"END:VCARD"
].joined(separator: "\n")
do {
try vCardString.write(toFile: vCardFileURL.path, atomically: true, encoding: .utf8)
} catch let error {
print("Error, \(error.localizedDescription), saving vCard: \(vCardString) to file path: \(vCardFileURL.path).")
}
print(vCardString)
return vCardFileURL
} // end of function
Run Code Online (Sandbox Code Playgroud)
//调用上方的聚会
let vURL = LocationVCard.vCardURL(from: self.newLocation.coordinate, with: "Berlin")
let activityViewController …
Run Code Online (Sandbox Code Playgroud) 我正在尝试从WKWebView打印.网页和图片工作正常.
仅当我打印PDF文件时,页面都是空白的.
这是我用来创建printController的代码:
let printController = UIPrintInteractionController.sharedPrintController()
let printInfo = UIPrintInfo(dictionary:nil)
printInfo.outputType = UIPrintInfoOutputType.General
printInfo.jobName = urlField.text!
printInfo.duplex = UIPrintInfoDuplex.LongEdge
let formatter: UIViewPrintFormatter = webView.viewPrintFormatter()
formatter.contentInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
printController.printFormatter = formatter
printController.printInfo = printInfo
printController.showsPageRange = true
printController.showsNumberOfCopies = true
printController.presentFromBarButtonItem(printButton, animated: true, completionHandler: nil)
Run Code Online (Sandbox Code Playgroud)
有人能帮助我走向正确的方向吗?有这个问题的解决方案吗?
pdf uiprintformatter uiprintinteractioncntrler swift wkwebview