Hi Kim
SearchTextChanged it called as you type, so it should go each time you
hit a key.
To get rid of the keyboard, you need to use the ResignFirstResponder
method, or you can try setting EndEditing to true (you need to either
call it on the searchbox, or on the dialogviewcontroller itself)
As for the rest of it (pun kind of intended), I would:
1. get the SearchTextChanged event, and start a timer. if the timer
fires, keep going. If the user hits another key, restart the timer.
2. when the timer fires, start a new thread (ThreadPool, or use
System.Threading.Tasks) and do your rest call.
3. Once you have the data, use InvokeOnMainThread (which is on any UI*
object, or even NSString or NSObject) to pass in the results of the
search, and update the dialogviewcontroller. You MUST do the update on
the UI thread, and unless you want the UI to jump and around and stop
and stutter, you need to do the rest call (and any other non-UI
processing) OFF the main thread.
How you do the update is up to you. For a first attempt, just rebuild
the Root and reload it. If thats not smooth enough, you may need to
take the current root, insert the new results in the right places, and
allow it to animate the table cells (you get the animations for free,
pretty much)
//in a thread, do the rest calls
ThreadPool.QueueUserWorkItem(delegate {
var results = DoSomeWorkAndGetSomeResults(searchText);
//once you have the results, update the UI - check to see if the
object you are using has InvokeOnMainThread, if so, you dont need to
make a string to use it :)
var temp = new NSString("foo");
temp.InvokeOnMainThread(delegate {
var localresults = results; //keep a reference to it
var newroot = new RootElement("results!");
//add in secetions and elements based on your rest results
foreach(var result in localresults) {
//do stuff, make objects, put them into the root
}
Root = newroot; //display it.
});
});
On Wed, Jun 27, 2012 at 1:50 PM, tiede <[email protected]> wrote:
> I am new to mono touch and iOs programming.
>
> I am considering using the mono touch dialog for showing a search result
> from a REST service. So the table is initially empty but by pressing the
> search button (search is enabled in the dialog viewcontroller).
>
> Is this an ok use of the dialogviewcontroller? And what it the right pattern
> for calling the service and supplying the result into the "model" of the
> controller?
>
> I have tried implementing in the SearchButtonClicked and that works but the
> keyboard does not disappear. I have tried in the SearchTextChanged but the
> data is not refreshed.
>
> So I am looking for a pattern for this kind of use case?
>
> Thanks in advance
>
> Kim
>
> --
> View this message in context:
> http://monotouch.2284126.n4.nabble.com/DialogViewController-and-async-search-tp4655604.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
--
Nic Wise
t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/
Earnest: Self-employed? Track your business expenses and income.
http://earnestapp.com
Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch