- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图让 DTCoreText 改变一些来自 JSON 的简单 HTML。我试图实现他们在示例中给出的简单“烟雾文本”,但我在让开关正常工作时遇到了问题。有没有人在swift 3中用过。
我不确定此时我是否真的在使用 DTCoreText。
func updatethePage(){
if let items = self.swiftyJsonVar2["daily"]["leadmessage"].string {
data = items.data(using: .utf8)
attrString = NSAttributedString(htmlData: data,options:nil, documentAttributes:nil)
print(attrString)
self.leadStory.attributedText = attrString!
}
}
我现在让它运行了,但它抛出的错误是
Optional(This is the lead message
And naother line
{
CTForegroundColor = "<CGColor 0x600000085c80> [<CGColorSpace 0x6000000348e0> (kCGColorSpaceICCBased; kCGColorSpaceModelMonochrome; Generic Gray Gamma 2.2 Profile; extended range)] ( 0 1 )";
NSFont = "<UICTFont: 0x7f8abb50f270> font-family: \"Times New Roman\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
NSParagraphStyle = "<CTParagraphStyle: 0x6080000d0840>{base writing direction = -1, alignment = 4, line break mode = 0, default tab interval = 36\nfirst line head indent = 0, head indent = 0, tail indent = 0\nline height multiple = 0, maximum line height = 0, minimum line height = 0\nline spacing adjustment = 0, paragraph spacing = 12, paragraph spacing before = 12\n}";
})
2016-10-06 11:14:56.485 JSONTesting[61040:4582698] -[__NSCFType lineBreakMode]: unrecognized selector sent to instance 0x6080000d0840
2016-10-06 11:14:57.251 JSONTesting[61040:4582698] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType lineBreakMode]: unrecognized selector sent to instance 0x6080000d0840'
*** First throw call stack:
(
0 CoreFoundation 0x000000010876534b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001081c621e objc_exception_throw + 48
2 CoreFoundation 0x00000001087d4f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00000001086eac15 ___forwarding___ + 1013
4 CoreFoundation 0x00000001086ea798 _CF_forwarding_prep_0 + 120
5 UIFoundation 0x0000000110c028bd __NSStringDrawingEngine + 647
6 UIFoundation 0x0000000110c0b3d4 -[NSAttributedString(NSExtendedStringDrawing) boundingRectWithSize:options:context:] + 797
7 UIKit 0x000000010906eb18 -[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:] + 1199
8 UIKit 0x000000010906e42f -[UILabel textRectForBounds:limitedToNumberOfLines:] + 68
9 UIKit 0x0000000109073f53 -[UILabel _intrinsicSizeWithinSize:] + 168
10 UIKit 0x0000000109073916 -[UILabel _ensureBaselineMetricsReturningBounds] + 196
11 UIKit 0x0000000109073a89 -[UILabel _baselineOffsetFromBottom] + 31
12 UIKit 0x00000001090723b4 -[UILabel _baselineOffsetParametersDidChange] + 98
13 UIKit 0x000000010906ffc0 -[UILabel _setAttributedText:andTakeOwnership:] + 229
14 UIKit 0x0000000109070044 -[UILabel setAttributedText:] + 115
15 JSONTesting 0x00000001075de10d _TFC11JSONTesting21importantWPController13updatethePagefT_T_ + 2637
16 JSONTesting 0x00000001075dd334 _TFFC11JSONTesting21importantWPController10updatePageFT_T_U_FGV9Alamofire12DataResponseP__T_ + 868
17 Alamofire 0x0000000107787f59 _TFFFC9Alamofire11DataRequest8responseuRxS_30DataResponseSerializerProtocolrFT5queueGSqCSo13DispatchQueue_18responseSerializerx17completionHandlerFGVS_12DataResponsewx16SerializedObject_T__DS0_U_FT_T_U_FT_T_ + 889
18 Alamofire 0x0000000107787fb7 _TTRGRx9Alamofire30DataResponseSerializerProtocolrXFo___XFdCb___ + 39
19 libdispatch.dylib 0x000000010bf78980 _dispatch_call_block_and_release + 12
20 libdispatch.dylib 0x000000010bfa20cd _dispatch_client_callout + 8
21 libdispatch.dylib 0x000000010bf828d6 _dispatch_main_queue_callback_4CF + 406
22 CoreFoundation 0x00000001087294f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
23 CoreFoundation 0x00000001086eef8d __CFRunLoopRun + 2205
24 CoreFoundation 0x00000001086ee494 CFRunLoopRunSpecific + 420
25 GraphicsServices 0x0000000110599a6f GSEventRunModal + 161
26 UIKit 0x0000000108de7f34 UIApplicationMain + 159
27 JSONTesting 0x00000001075d577f main + 111
28 libdyld.dylib 0x000000010bfee68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
最佳答案
我必须将其放入 DTCoreText ViewContent 而不是普通标签。
关于ios - DTCoreText 与 Swift 3 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39897003/
我使用 DTCoreText 在 iOS 中呈现 HTML 文档。我注意到有些图像没有显示。这些图像在 src 中具有相对 url。当我将 src 值更改为文件名并将图像放置到与 html 文档相同的
我得到错误: -[__NSCFType lineBreakMode]: unrecognized selector sent to instance 当以下代码完成执行时: NSDictionary
我正在使用 DTCoreText 显示 HTML 代码。到目前为止一切正常,但现在我在此 HTML 代码中收到嵌入的推文,但它们无法正常工作。 正如 Twitter 文档中所说,推文嵌入了 block
xcode 4.5.2 DTCoreText1.1 我尝试了很多方法,但都失败了。有人有这方面的经验吗? 如何将DTCoreText集成到新项目中? 我将我的文件上传到 www.uethink.com
我之前就这个问题提出了一个问题,但我已经清理了项目并从头开始重新启动。 我正在尝试使用 DTCoreText 我的播客文件: platform :iOS pod 'DTCoreText' ^quote
我想使用 DTCoreText在我的应用程序中将 HTML 转换为 NSAttributedString,但我不知道如何使用系统字体(从 iOS 8 开始:Helvetica Neue)作为基本字体。
我试图实现 DTCoreText .我关注这个guide并将其实现为 git submodul,但现在当我尝试运行我的应用程序时出现错误。目前我没有使用 DTCoreText 进行任何编码。我只想测试
我想使用 DTCoreText 从 HTML 到 NSAttributedString 有多个/嵌套的超标. 如果我采用以下 HTML: Some text with a superscript 在
我试图让 DTCoreText 改变一些来自 JSON 的简单 HTML。我试图实现他们在示例中给出的简单“烟雾文本”,但我在让开关正常工作时遇到了问题。有没有人在swift 3中用过。 我不确定此时
let callBackBlock:(DTHTMLElement) -> Void = { element in for oneChildElement in element.chil
我使用 DTCoreText 的 DHTMLAttributedStringBuilder 在 UITableViewCell 中显示 HTML 代码。但它有一个错误。这是我的代码: NSDictio
我想从 html 转换为 NSAttributedString,我发现在这里使用 DTCoreText 解决了这个问题 https://github.com/Cocoanetics/DTCoreTex
我正在使用 DTCoreText 创建 HTML 属性字符串。 DTCoreText 返回的属性字符串有一个名为“CTForegroundColor”的属性,其中包含文本颜色信息。当我在 UI 上显示
我是 Objective-C 的新手,我试图在我的项目中使用 DTCoreText 来获取 html 内容。我点击了这个链接( https://github.com/yas375/DTCoreText
我有 DTAttributedTextContentView,我成功地从 HTML 渲染文本。现在我想嵌入与文本内嵌显示的图片。我查看了文档,只有 Objective-C 示例。如何在 Swift 上
我是一名优秀的程序员,十分优秀!