MonoTouch - reusing UIAlertVIew?

Should I reuse UIAlertView instances when possible?

Or do they wrap best practice in the block used?

  • In one situation, I created a (non-modal) MessageBox class (just like WinForms or WPF). I mainly use this for convenience.
  • Another situation is the custom of UIAlertView, that I have subclassed it has a more advanced layout. I am hooking the Dismissal event to do some work on closing.

Can any of these situations use a different approach?

+3
source share
2 answers

, - , - , , .

LoadingHUDView ...

- , , - , IMO

+2

UIAlertView:

, mainloop . mainloop , mainloop 0,5 .

, :

int WaitForClick ()
{
    int clicked = -1;
    var x = new UIAlertView ("Title", "Message",  null, "Cancel", "OK", "Perhaps");
    x.Show ();
    bool done = false;
    x.Clicked += (sender, buttonArgs) => {
        Console.WriteLine ("User clicked on {0}", buttonArgs.ButtonIndex);
    clicked = buttonArgs.ButtonIndex;
    };    
    while (clicked == -1){
        NSRunLoop.Current.RunUntil (NSDate.FromTimeIntervalSinceNow (0.5));
        Console.WriteLine ("Waiting for another 0.5 seconds");
    }

    Console.WriteLine ("The user clicked {0}", clicked);
    return clicked;
}
+2

Source: https://habr.com/ru/post/1762742/


All Articles