ios - NSHTMLTextDocumentType not showing in attributed text view for paged VC -
i'm trying format text within uitextview using nshtmltextdocumenttype. uitextview on page/vc of pageviewcontroller.
it works fine , when tested in simulator worked. except... when switched the device , started dragging between pages in pageviewcontroller text stopped showing. realised when using simulator on laptop click rather drag change pages.
so formatting works/fails in following situations:
- work: clicking quick automatic pagecurl affect between pages
- work: programatically changing pages via timer
- fail: dragging pagecurl affect between pages
interestingly, when page fails render text dragging next page:
- the code being called properly. debug , see being set. attributed text showing right values.
- when rotate device page redrawn puts text there (so vc has info viewdidload isn't run on orientation change).
my theory rendering of html slow pagecurl effect get's vc before rendered , doesn't show text.
my code rendering textview in viewdidload , looks below. 3 methods use same functional generate vc.
//set html text var htmldata:string = "<p><h1>test</h1></p>" htmldata += "<p>some <b>more</b> text</p>" htmldata += "<ul><li>1</li><li>2</li></ul>" //convert html attributed text let attributeddata = htmldata.datausingencoding(nsunicodestringencoding) informationtextview.attributedtext = try! nsattributedstring(data: attributeddata!, options: [nsdocumenttypedocumentattribute: nshtmltextdocumenttype], documentattributes: nil) //set font if let font = uifont(name: "stoneserifmedium", size: 12.0) { informationtextview.font = font } //force scrollable area top left informationtextview.setcontentoffset(cgpointmake(0, -999), animated: true) questions:
- how make page curl show attributed html text?
- failing that, should using text formating? noticed seem slow. main feature want bulleted list section of text. doesn't appear in normal attributed text functionality.
when running on device (not in simulator) noticed getting warning bogus layer size:
2016-01-08 12:43:06.640 thaifootmassage[7061:4333540] -[<_uitilelayer: 0x15fea56a0> display]: ignoring bogus layer size (3163616608641188102144.000000, 2361183241434822606848.000000), contentsscale 2.000000, backing store size (6327233217282376204288.000000, 4722366482869645213696.000000) also noticed text appear down page quickly, disappear.
commenting out following line fixed warning , started showing text:
//force scrollable area top left //informationtextview.setcontentoffset(cgpointmake(0, -999), animated: true) i assume attributable text (html) allows blank area above rendered text scrolling off bottom. plain text stop @ top.
Comments
Post a Comment