uiwebview

Creating webViews programmatically in Swift

荒凉一梦 提交于 2019-11-30 12:17:49
I want to create something like an image gallery in my ViewController. For this, I'd need multiple webViews, depending on the number of images that I get from a JSON request. How can I insert new webViews if I need to? As you can see in the above image, I have a scrollView and one UIWebView inside of the ViewController. How would I create a new webView inside of the first(second, third, etc.) if necessary? Is it possible? you can create the web view programatically as simple as possible use this piece of code override func viewDidLoad() { super.viewDidLoad() let webV:UIWebView = UIWebView

Testing UIWebView with Xcode UI Testing

谁说我不能喝 提交于 2019-11-30 12:02:40
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: let app:XCUIApplication = XCUIApplication() let webViewQury:XCUIElementQuery = app

Why Shouldn't A UIWebView Be Placed in a UIScrollView?

一笑奈何 提交于 2019-11-30 11:52:50
问题 The Question Does anyone know of technical reasons for avoiding web views inside scroll views on iOS (assuming you're willing to disable scrolling inside the web views themselves)? If you look at the Apple docs for UIWebView, they state: Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled. My Educated Guess It looks like maybe they're

tableView:indexPathForCell returns nil

陌路散爱 提交于 2019-11-30 11:48:26
问题 I am using the method tableView:indexPathForCell to implement a custom delegate that can dynamically resize a UITableViewCell based on the frame size of the UIWebView that is inside of it. The problem is that tableView:indexPathForCell is returning nil when I try to find out what the indexPath of a particular cell is: - (void)trialSummaryTableViewCell:(TrialSummaryTableViewCell *)cell shouldAssignHeight:(CGFloat)newHeight { NSIndexPath *indexPath = [tableV indexPathForCell:cell]; NSLog(@

How to detect touch on UIWebView

喜欢而已 提交于 2019-11-30 11:39:29
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? 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.delegate = self; [offScreenWebView addGestureRecognizer:webViewTapped]; [webViewTapped release]; Step 2:

iPhone app crashes on WebThread MPVolumeSlider

北慕城南 提交于 2019-11-30 11:27:15
It seems like very broad to ask a question, but this is very annoying and difficult to fix the bug. Here's the crash log for WebThread which I got from Crashlytics. Thread : Crashed: WebThread 0 libobjc.A.dylib 0x0000000193e97bd0 objc_msgSend + 16 1 UIKit 0x0000000187f65dd8 +[UIViewAnimationState popAnimationState] + 332 2 MediaPlayer 0x0000000185953358 -[MPVolumeSlider volumeController:volumeValueDidChange:] + 92 3 MediaPlayer 0x00000001859c5fc4 -[MPVolumeController updateVolumeValue] + 260 4 MediaPlayer 0x0000000185952cb0 -[MPVolumeSlider didMoveToSuperview] + 144 5 UIKit 0x0000000187f2c1dc

iOS - UIWebView not working due to parsing error

南笙酒味 提交于 2019-11-30 11:24:42
问题 I want to play a Youtube video in my app. So, I wrote the following code NSString *embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>"; NSString* html = [NSString stringWithFormat:embedHTML, videoURL, self.view.frame.size.width, self.view.frame.size.height];

Programmatically select text in UIWebView

被刻印的时光 ゝ 提交于 2019-11-30 11:20:16
I'm asking this question after 2 days of research. I've read all the related questions and answers in stackoverflow and google (including this question, which is very similar but without an answer) and still couldn't find a solution. Hopefully someone here will be able to help. I have a UIWebView with some text loaded into it. I want to select part of the text programmatically, as if the user long-pressed on it. I've tried executing this javascript code as a response to a click: function selectEl(x,y) { document.designMode = "on"; var el = document.elementFromPoint(x, y); var range = document

How to detect when a UIWebView has completely finished loading?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 11:18:05
I am trying to build a filter for a UIWebView and I am struggiling to detect when the UIWebView has completely finished loading. I have used the following two methods – webView:shouldStartLoadWithRequest:navigationType: – webViewDidFinishLoad: but the issue is that these will be called multiple times when a page has frames and additional content to load. What I need is to know when the view has completely loaded and there is no more content to fetch. Then when the content has loaded I can check to URL of the page against a list of approved URLS. ANy ideas? Use the UIWebViewDelegate protocol

How can I search in an UIWebView?

泄露秘密 提交于 2019-11-30 10:47:47
I need to perform search in an html page displayed in a UIWebView control. The functionality I need is something that Safari has, when you hit command/ctrl F for searching the document for some word and the program highlights the hits for you. Is there any easy solution for this problem? I know it's been a long time since you asked this question, but it's still a pretty common question people have so I put together a sample project in case anyone else is asking the same question. The project is a super simple app that loads an HTML file and can search and highlight any keyword. You can