Uiwebview shouldloadrequest not getting called sometimes - iphone

I am using nine webviews inside a scrollview to get an infinte scrolling effect. I am loading image map inside each webviews. Now the problem is webviews are not responding sometimes for the touches, when it is a hard-touch(touch and hold). I am getting this issue when more than one webviews are visible. I have set the delegate for every webviews, I dont know why this happening.
I am loosing the selection while holding it, its grey color dissappears. This issue I am getting only in 3.2iPad device.
I need to get the shouldStartLoadWithRequest method called while each press. what i need to do?
thanks in advance,

You have to read the Apple document for UIWebview, they are clearly saying,"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."
check this link:- http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html
But I also do adding UIWebview to UIScrollview, But in my case the frame of a webview is same as the frame of scrollview. In this case the touchevent is properly detected.
And One issue I found in this case we can get UITapGestureRecognizer from that Uiwebviews...

Related

UIKeyboard pushing UIWEBVIEW

Currently the way ios handles input fields in the uiwebviews is by pushing the uiwebview up when u tap on the input field in a uiwebview. Sometimes, the uiwebview goes outside the page. I was wondering how the whole things work? My parentviewcontroller doesn't have any scrollview inside etc.. but yet it pushes the uiwebview up.
Any idea how I can prevent the keyboard from pushing the uiwebview up. How does it know by how much it needs to push up. I added a method to get the information about the keybaord when it shows up and the size of the keyboard which is returned is 1024px for the height which is really weird.
Thanks.

iPhone: Best way to handle 400 UILabels in UIScrollview

I've been working on a crossword app for a while. The actual game runs in a UIScrollview, because the player should be able to scroll, zoom and pan.
To the UIScrollview i added a UITapGestureRecognizer that handles the touch-event, and calculates where the player touched. So far so good.
Afterwards I added about 400 UILabels to the UIScrollview. Each of them are "empty" until the player presses a button on the keyboard. My problem is that when i add these labels the whole UIScrollview become very slow and laggy in scrolling etc.
As the user guesses the right words green tiles will become visible. The tiles are loaded in as UIImageViews. This reduces the performance again.
I have looked at DTGridView, but I've got no luck with it.
Can you please help me out and try to guide me in the right direction?
i think you should implement the UIScrollview method drawRect you self instead of add 400 UILabel in it
you can set a NSArray contains 400 objects called "label";
when user pressed the button, you should calc the postion & test of the "label" &decide which "label" should display in the scrollview in current offset .
add 400 UILabels in one UIScrollview may cause the memory problem;
You need to use recycled label in your scrollview. That will improve the performance. To know how to reuse/recycle subviews in UIScrollView please check Apple WWDC videos on UIScrollView. WWDC 2010 Sample Code . Also check UIScrollView Class Refference UIScrollView Class Reference
You can get help from this link Creating Circular and Infinite UIScrollViews
I've been playing with this for the past while/days even. Using various related answers. But eventually I used instruments and a bit of commenting to see what was slow.
I remember someone saying layoutSubviews slows things when you addSubviews, so I took my "Local" code out of there. But nothing sped up.
So when using a breakpoint during my addSubview routine, I noticed the iOS system was actually in a superview's layout calls (navigationCtrlr) during viewDidLoad.
I introduced a 0.1 second delay before adding subviews and bam! I recommend dispatch_async to prevent crashes from race conditions, but that's another subject.
In short, it might be in LayoutSubviews even if you don't think you are there.

loadHTMLString won't fire while UIScrollView is scrolling

I'm trying to lazy load UIWebViews inside a UIScrollView.
Every time the user scrolls, the WebViews frames are updated and new content SHOULD be loaded. And that's exactly where I'm having trouble. The repositioning works well, but the new content (local NSStrings, which are called using loadHTMLString) does not appear until I stop scrolling the ScrollView.
I've read this thread already: NSURLRequest won't fire while UIScrollView is scrolling.
Getting some inspiration from that, is there any association I could make between loadHTMLString and NSURLConnection? I know next to nothing about NSURLConnection.
If that's not possible, is there any other solution? Either halting the scroll for a while (like MobileRSS – an App Store app – does) or alternate loading methods?
Edit: My UIScrollView has paging enabled. So if I were to halt the scroll for a while, it should happen at every page. But I still don't know how to accomplish that.
Old question, but here is an answer for it.
You'll have to subclass the UIWebView and switch the run loops started at a overridden loadHTMLString:baseURL:
and switching it back after the html has been loaded (or failed to load).
Check out this project on github which gives you an example of where to override in all the right places.

UIScrollView with embedded UIWebView not scrolling after holding

I have a UIWebView which is embedded in a UIScrollView. The webView is resized so that the scroll view manages all the scrolling (I need control over the scrolling).
In the webView I have disabled userSelection via '-webkit-user-select: none;'
Everything is working fine except one annoying detail. When I hold down my finger on the content before starting to scroll for about a second the scrollView won't scroll. My best guess is, that it has something to do with userSelection. The time is about the same it usually takes for the copy/paste/magnifying-thing to appear which usually disables scrolling as well.
I am running out of ideas on how to solve this. Every help would be greatly appreciated!
Thanks!
EDIT: Another aspect of the problem is, that the non-scrolling actually triggers JS-Eventhandler (click, mousedown, mouseup) inside my webView which leads to surprising app behavior. The user puts her finger down, waits, scrolls, nothing happens, removes her finger and this is perceived as a click, which feels wrong from a users perspective.
I would guess what is happening is that after that short duration, the scrollview is no longer interpreting the touch as being on it's view and instead passes the touch down to it's content views.
Have you tried delaying the content touches for the scrollview? This will essentially tell the scrollview to delay taking action on the touch event and instead to briefly monitor the touch and if the touch moves then it recognizes it as a swipe gesture for scrolling. If it doesn't move, it will eventually pass the touch along to it's subviews.
scrollView.delaysContentTouches = YES;
I think even then, there is a standard delay time before the scrollview will pass the touch events along the responder chain. If you hold for too long, it's going to naturally perceive it as being a press down event rather than a scroll event.
This question is not relevant anymore. As of iOS 5.0 the UIWebView is based on a real UIScrollView and also exposes that UIScrollView via a property. Use that instead.
And don't mess with UIWebViews embedded in UIScrollViews anymore. The documentation explicitly advises against that.
Relevant Documentation

Strategy to lazy load images for buttons within UIScrollView?

I have a horizontal UIScrollView that contains UIButtons (though it could be any object). I would like to only download images for these buttons as the user scrolls and they are seen. I would also like an activityindicator running on each button while the images are downloading. Here's what I've tried with results:
Check content offset of uiscrollview and download images for visible buttons. Problem: issues getting activity view shown within subclassed UIButton and not desired usability since images are only downloaded once scrolling stops.
Add subviews (not buttons) to the UIScrollview hoping to use the view's ViewController to initiate a downloaded on viewDidAppear. Problem: viewDidAppear never seems to get called (because I am using addSubView?).
I've seen other apps that do this kind of loading but need some guidance on the typical set-up. Ebay's app is a great example. All items have a default image until the item comes into view, then an activityindicator runs and the items unique image is downloaded.
Thanks for assistance.
Without actually trying it out, here's my idea:
You can use the UIScrollViewDelegate method scrollViewDidScroll: to find out when your scroll view finished scrolling and then use [UIScrollView contentOffset] to determine which part of the scroll view is visible and (CGRect)convertRect:(CGRect)rect fromView:(UIView *)view to determine the button's position within the visible part of the scroll view. Have a method that checks if the button has had its image loaded yet and if not, load it and refresh the view if necessary.
Most such apps are using a UITableView, not a plain scroll view. Joe Hewitt's Three20 framework has a TTImageView class that can do lazy image loading and is pretty well suited to this kind of use.