uiwebview

How to display html formatted text in ios label

纵饮孤独 提交于 2019-11-29 22:08:40
I would like to display html formatted text on a UILabel in IOS. In Android, it has api like this .setText(Html.fromHtml(somestring)); Set TextView text from html-formatted string resource in XML I would like to know what / if there is an equivalent in ios? I search and find this thread: How to show HTML text from API on the iPhone? But it suggests using UIWebView . I need to display html formatted string in each table cell, so I think have 1 webview per row seems a bit heavy. Is that any other alternative? Thank you. ƒernando Valle Swift 3.0 do { let attrStr = try NSAttributedString( data: "

Reusing UIWebView is causing crashes

断了今生、忘了曾经 提交于 2019-11-29 21:04:26
问题 I've read that reusing UIWebViews is kind of a bad practice. Some code I inherited at work is pushing a variety of content to a UIWebView. Powerpoints, Word documents, and video. This all works just fine under normal circumstances. When we get to switching out the content in the UIWebView too fast, it dumps. My webView is set as a property. It is hooked up in IB just fine. Normal selection from our tableView loads local content just fine. It takes rapid fire selection of either the same cell

EXC_BAD_ACCESS in UIWebView

自作多情 提交于 2019-11-29 20:18:52
I just downloaded the crash reports for one of my iPhone apps from iTunes Connect. The most common crash has a trace like the following: Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0xa1b1c1db Crashed Thread: 0 Thread 0 Crashed: 0 libobjc.A.dylib 0x3030e6f4 objc_msgSend + 16 1 UIKit 0x30ebebee -[UIWebView webView:resource:didFinishLoadingFromDataSource:] 2 UIKit 0x30ebe5ca -[UIWebViewWebViewDelegate webView:resource:didFinishLoadingFromDataSource:] 3 CoreFoundation 0x32b73b5c __invoking___ + 60 4 CoreFoundation 0x32bc67be -[NSInvocation invoke] 5 WebCore

Black line appearing at bottom of UIWebView. How to remove?

回眸只為那壹抹淺笑 提交于 2019-11-29 19:50:41
I am rendering some html in a webview that is embedded in a table cell. For some reason there is a black line at the bottom of the webview. I tried setting the background color of the webview and its scrollview to white but this did not change anything. Has anyone seen this before? Here is the HTML that is being rendered: <html> <head> <style type="text/css"> a {text-decoration:none;background-color:white;} </style> <title></title> </head> <body style="margin:0;padding:0;background-color:white;"> <a href="http://body/" style= "font-family:HelveticaNeue-Light;font-size:20.000000;color:black;

Suppress WKWebView from scaling content to render at same magnification as UIWebView does

故事扮演 提交于 2019-11-29 19:35:45
Problem Using WKWebView in place of UIWebView , I noticed that the contents of the WKWebView were massively scaled down as compared to my UIWebView . I'd like the WKWebView to stop doing that, and just respect my CSS values literally, the way UIWebView would. Context I use web views in my native iOS app for the contents that go inside popovers on an iPad where I'm displaying informational content. It's great being able to give this to content and design folks and say, "just drop in some HTML content, referencing the linked CSS file". All of this worked just great when using UIWebView . But

Cookies in UIWebView

南楼画角 提交于 2019-11-29 18:32:00
问题 I have a UIWebView, and I don't want it to store an cookies, so just before the webview is loaded I do: NSArray* cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]; for (NSHTTPCookie *cookie in cookies) { [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie]; } Checking the count of cookies is 0 so they are all deleted. But when I go to stackoverflow it still recognizes my Google Account and logs me in. How does this happen? I though it worked with cookies? 回答1: I

How to load a url link that is inside a web view and keep it in that web view in SWIFT

放肆的年华 提交于 2019-11-29 18:03:49
I have a web view that has a webpage with links at the bottom. I have a way to deal with them being clicked, but all it does is open them into a new safari browser. This is not what I want.I would like for them to stay inside the web view and allow me to navigate them easily like that. Is there a way to do this? I have tried just using a regular web view, but then the links at the bottom will not work. Here is what I have so far: class ViewController: UIViewController, UIWebViewDelegate { @IBOutlet weak var myWebview: UIWebView! @IBOutlet weak var returnButton: UIButton! override func

Play embedded video in UIWebView with HTML5

北战南征 提交于 2019-11-29 18:02:17
I'm actually trying to play a local video into an UIWebView, with HTLM5. What I do actually is this : NSString *embedHTML = [NSString stringWithFormat:@"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ < src=\"%@\" \ </embed>\ </body></html>", [[NSBundle mainBundle] pathForResource:@"ash(1).mov" ofType:nil]]; [webView setOpaque:NO]; NSString *html = [NSString stringWithFormat:embedHTML, webView.frame.size.width, webView.frame.size.height]; [webView loadHTMLString:html baseURL:nil]; I have on my

Testing UIWebView with Xcode UI Testing

谁都会走 提交于 2019-11-29 17:51:58
问题 I'm using new Xcode UI Testing from XCTest Framework with the Xcode 7 GM . I've got an app with simple UIWebView (it's just a navigation controller + view controller with web view and button) and I want to check following scenario: Web View loads page www.example.com User taps on button Web View loads some page with URL: www.example2.com I want to check which page is loaded in UIWebView after pressing button. Is this possible with UI Testing right now? Actually I'm getting web view like this:

How to detect touch on UIWebView

房东的猫 提交于 2019-11-29 17:21:56
问题 On UIWebview, how can I detect a touch? But not when user clicks some URL or touching a control. Is it possible to handle it? 回答1: Use UIGestureRecognizerDelegate method: Add UIGestureRecognizerDelegate in declaration file (i.e. your .h file) Step 1: Just set the delegate of gestureRecognizer: (in .m file viewDidLoad) UITapGestureRecognizer *webViewTapped = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)]; webViewTapped.numberOfTapsRequired = 1; webViewTapped