I have a UIWebView with some links in it. When I click the link, there's a delay of about 2-3 seconds before the link is loaded. Is this how it's suppose to be or is there a setting I can change?
Thanks.
In iOS5 the UIScrollView belonging to a UIWebView has been exposed so that you can change its behavior. So to remove the click delays you can simply do:
[webView.scrollView setDelaysContentTouches:NO]
This way you don't have to use any javascript libraries to remove the delay.
As a bonus, you can make the scrolling in a UIWebView feel a bit more native by changing the decelerationRate:
[webView.scrollView setDecelerationRate:UIScrollViewDecelerationRateNormal]
If you mean that after clicking the link there is a delay before the the link is highlighted, this has to do with how the touches are handled by the UIWebView. I doubt that this can account for the whole 2-3 secs delay, but anyway refer to this post to remove it.
If you mean that after clicking on a link it takes 2-3 seconds until you can see the page rendered, then it is (unfortunately) normal. UIWebView is known for being slow at rendering even a simple page.
Check if you are calling the load method on main thread or not. If you are testing it on Simulator then calling a method on secondary thread takes some time to execute rather than crashing or throwing an exception. Replace such call (if any) by performSelectorOnMainThread method.
Related
I have already made this kind of thing maybe one hundred times but, this time I'm so disturbed:
I have an UITableView with custom UITableViewCell which loads a picture via AFNetworking [-setImageWithURLRequest:]; and when I run the app, the content of the tableview doesn't appear.
If I wait, 8 seconds later, the content appears but if I made an interaction like scrolling, the content appears immediately. So strange.
I already tried to solve the issue with this article: http://blog.slaunchaman.com/2011/08/14/cocoa-touch-circumventing-uitableviewcell-redraw-issues-with-multithreading/ but without success.
Thank you.
Sounds like you are updating your table's contents off the main thread (UI thread), without seeing any code this would be my best guess.
I'm getting a "Slow defaults access for key ClientState took 0.034635 seconds, tolerance is 0.020000" warning when testing my iOS app - it seems to occur intermittently. I've tried to look around to see what it is about, but I'm not entirely sure! Any help appreciated, thanks.
My best guess is that the first Viewcontroller is taking to long to load.
I never got this message until adding a large background png to the first view controller which now exhibits the same behaviour but all the time. Take out the png and I did not get it on 5 loads.
Guessing same as depicus: first viewController loads too long.
In my case app starts by populating tableView from last saved CoreData. Right after that server tells me authorization has expired, I start re-auth and facebook login view comes on-screen - on top of tableView.
This is were I get that error. Without facebook login, everything is ok == fast enough.
SMSidat - I had the same problem and was looking found forever. I have an sqlite database and upon loading the vc that accessed the database it stated "slow defaults .....clientState took to long to load and all.
Try to remove Auto Layout from your nibs. Once I did that, no more "slow defaults...warning"!! Even though this is from 3 years ago...Hope it can help someone out.
Here is a link to the tread that helped me out
Slow UIViewController load time (slow ClientState warning)
In my experience this is cause by the time it takes to load a view when you invoke it. Take my case for example. I had a TabBar app and in one of my tabs it was a gallery. I was calling the view but within the view I was fetching everything on the main thread (big no no)... obviously, User interaction was gone out the window and the app will lock until done. The phone will take its time to load the images and to present the view. Once I multi-threaded my application and the pictures loaded in the background no more warning. Hope that helps, I am not sure how this warning works underneath but that changing this things got rid of it. :)
Hello I have a problem with UITableView freeze,
"downloadItem" below gets called when someone clicks on a button on the iPad. Its supposed to download a file and then return.
During the download, while stuck in that function, I want the UI to still be responsive, so I installed a runloop like below.
The actual downloadItem function is WAY more complicated than shown below, but what is shown is the basic idea of it. I know this isn't the best way, but for other reasons, I can't change it at this time, especially due to the existing complexity of the actual function.
The problem is that I also have a UITableView on the screen (as well as the button), if the UITableView is clicked or scrolled while in this function, in the runloop, the UITableView sometimes freezes up, and remains frozen even after exiting this function. This doesn't happen every time for some reason, maybe 40% of the time.
Does anyone know how to fix, is the RunLoop call below done right? Why when I click on the UITableView while in the runloop below, the table sometimes freezes up?
-(IBAction) downloadItem
{
BOOL downloading=TRUE;
callFunctionsToStartdownload(...);
while (downloading) {
downloading=DownloadSomeBytes(...);
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, YES);
}
}
thanks
In general, this seems unnecessary. You want the processing of downloaded bytes to be in a thread (which this does not address), but the actual asynchronous NSURLConnection should do its work in a thread (and then calls back to the thread that started it).
Im trying to find the best way to avoid having tiny UI lockups after certain events in my app. For example here are two cases where i have come across mini-lockups:
I have a button that when pressed loads a local mp3 file (around 20-30mb) using AVAudioPlayer, calls the prepareToPlay method and then plays the audio file. The issue is that the button has the showsTouchWhenHighlighted flag set to yes and after pressing it it stays highlighted until the audio file begins playing which could take 1-3 secs.
Another similar example is using a navbar button to sort and reload the table data. There is a very short but noticeable lockup where the button remains highlighted until the table has reloaded.
Can anyone suggest a good approach to minimizing/eliminating these mini lockups? I didnt really come across any code to achieve this in any of the books/tutorials i read that dealt with tableviews and avaudioplayer. Should i be launching these actions on different threads?
thx
For number 1, your best bet is to load the item on a background thread and inform the user that you're doing so (either via a loading HUD or some other indicator). The simplest way of doing this will be to use - (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg;. If you're running iOS 4.0 + you may want to look into executing block callbacks and see if they will work for you.
For number 2, perform the sorting on the background thread or change your sorting method (consider using a sorted data structure rather than resorting after inserts?). reloadData should occur only on the main thread.
I'm an iPhone noob myself, but it sounds like your code is stuck doing synchronous actions, which will guarantee that your UI gets locked up until the action is done executing.
Although I don't have an explicit answer, look for asynchronous options to perform these actions as they will not lockup your UI. These are usually achieved through using threads or deferred objects. From my experience so far w/ Objective-C, most actions your program neds to take can be achieved through async actions.
I'm going to do some sophisticated things in the delegate's methods during scrolling. I'll also implement the dynamic preloading of contents, so that it's theoretically possible to scroll through a few hundret thousand images. But I fear, that every time I do the preloading action for the next big chunk in scrolling direction, the delegate will wait for the data source to deliver the data, and the whole scroll view will be freezed for that moment.
The problem is, that I need always access to the subviews of the scroll view. I'm new to the platform and I don't know if I would still have access when I open up another thread for that preloading actions? Or would the scrollview not wait for the delegate to get things done?
I'm in the planing phase, so haven't implementet much jet.
You can only use UI classes from the main thread. So what you should do is to compute as much as possible in a background thread (I believe you can load your images in a background thread too), and then use performSelectorOnMainThread:withObject:waitUntilDone: to manipulate UI classes on the main thread.
See How do I update the UI in the middle of this thread? for the another instance of your question
I don't have a specific answer, to your specific question. I just want to make sure you are aware of the ~25MB limit of RAM for your app. I can't give links on this, because even though Apple knows the limit, they aren't telling.