In my rich text project I use NSTextAttachment to add an image, set attachment.bounds, and it works. Convert NSAttributedString to NSData and store it in sqlite3 and then take it out. Attachment.bounds is lost.How to solve this problem? Thanks a lot.
attachment.image = image
let textPaddingTop:CGFloat = (richTextView.font!.lineHeight - richTextView.font!.pointSize) / 2
attachment.bounds = CGRect.init(x: 0, y: -textPaddingTop, width: image.size.width, height: image.size.height)
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
In my rich text project I use NSTextAttachment to add an image, but the image is blurred.How to solve this problem? Thanks a lot.
let textAttachment = NSTextAttachment()
textAttachment.image = image
textAttachment.bounds = CGRect(origin: CGPoint.zero, size: image.size)
let textAttachmentString = NSMutableAttributedString(attributedString: NSAttributedString(attachment: textAttachment))
textAttachmentString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paraph, range: NSRange(location: 0, length: textAttachmentString.length))
attributedText.append(textAttachmentString)
}
Test with iphone11(14.6) and watch series3(6.2)
In my project, I use WatchConnectivity between phone and watch to communication,
When watch send message with below code, every time run is OK
wcSession.sendMessage(message as [String : Any], replyHandler: nil)
But when watch send message need reply, it seems error.
wcSession.sendMessage(message) { (reply) in
} errorHandler: { (error) in
}
In Phone with below code to deal with request
func session(_ session: WCSession, didReceiveMessage message: [String : Any]) {
}
func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
}
I debug the code, didReceiveMessage replyHandler can be called, and reply data, but watch can not receive the reply. So what’s my problem, Before the mobile and watch update, everything is good, every update will cause problems, how to ensure the stability of the app?Thank you very much.