Re: WebView blocks User Interface
Re: WebView blocks User Interface
- Subject: Re: WebView blocks User Interface
- From: Scott Ribe <email@hidden>
- Date: Thu, 05 Dec 2013 09:16:03 -0700
On Dec 5, 2013, at 4:47 AM, Gerriet M. Denkmann <email@hidden> wrote:
> 10.9.0. Given a search field, the user enters some chars, and a WebView is filled with all words containing these chars.
>
> Works fine, but one problem:
> When the user wants all words containing "no" but types a bit slowly, then this happens:
>
> - actionMethodFromSearchField: sender
> receives "n"
> makes htmlContent for "n" (takes no time, but is about 2 million chars long)
> sends: [ webView loadHTMLString: htmlContent baseURL: nil ];
> returns after some fraction of a second.
> The user now has finally found the key labelled "O" and presses it, but it does not show in the SearchField. Instead the spinning beach ball appears.
>
> After 50 seconds the WebView shows its content, the spinning beach ball disappears, the "o" finally appears in the SearchField and actionMethodFromSearchField is called again, this time with "no" and all is fine from here on.
>
> How can I keep my user interface responsive?
As other have pointed out, 50s seems too long. Maybe you can restructure the HTML somehow?
Anyway, use a timer, every keystroke, instead of displaying the search, re-set an NSTimer to fire in, say, 0.25 seconds. Display the results when either they're short, or the timer fires because the user has paused in typing.
--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
(303) 722-0567 voice
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden