Daniele Davi'

Android Toast equivalent in iOS

If you wonder what the Java Toast equivalent of this iOS Objective C event would be than you are in the right place. Below is a sample of what I have written for iOS and Xamarin.iOS. This behave pretty much the same as Alert in Java using a Toast in place of the iOS UIAlert.

In Objective C:

NSString *message = @"Toast kind of message";
UIAlertView *toast = [[UIAlertView alloc] initWithTitle:nil
                                            message:message
                                           delegate:nil
                                  cancelButtonTitle:nil
                                  otherButtonTitles:nil, nil];
[toast show];
int duration = 1; // in seconds

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[toast dismissWithClickedButtonIndex:0 animated:YES];
});

And if you are using Xamarin.IOS you can do like this:

new UIAlertView(null, message, null, "OK", null).Show();

using UIKit; is required.