Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

display toast in xamarin IOS

[assembly: Xamarin.Forms.Dependency(typeof(MessageIOS))]
namespace Bahwan.iOS
{
    public class MessageIOS : IMessage
    {
        const double LONG_DELAY = 3.5;
        const double SHORT_DELAY = 2.0;

        NSTimer alertDelay;
        UIAlertController alert;

        public void LongAlert(string message)
        {
            ShowAlert(message, LONG_DELAY);
        }
        public void ShortAlert(string message)
        {
            ShowAlert(message, SHORT_DELAY);
        }

        void ShowAlert(string message, double seconds)
        {
            alertDelay = NSTimer.CreateScheduledTimer(seconds, (obj) =>
            {
                dismissMessage();
            });
            alert = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert);
            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alert, true, null);
        }

        void dismissMessage()
        {
            if (alert != null)
            {
                alert.DismissViewController(true, null);
            }
            if (alertDelay != null)
            {
                alertDelay.Dispose();
            }
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: swift await async 
Swift :: sizetofit not working swift 
Swift :: uialertcontroller example objective Code Answer 
Swift :: UITableViewRowAction access button 
Ruby :: rails kill server 
Ruby :: how to I change the name of a column in rails 
Ruby :: ruby uuid 
Ruby :: ruby filename from path 
Ruby :: brew update ruby 
Ruby :: ruby temporary files 
Ruby :: ruby memory location 
Ruby :: rails migration change type of column 
Ruby :: ruby attr_accessor multiple variables 
Ruby :: ruby multiline comment 
Ruby :: ruby integer to timestamp 
Ruby :: rails naming conventions controller 
Ruby :: rails add reference 
Ruby :: ruby median find 
Ruby :: Ruby ruby-2.6.3 is present on the following stacks: heroku 16 
Ruby :: starting delayed_jobs in local rails 3 
Ruby :: rails convert unix timestamp to datetime 
Ruby :: ruby list of files in directory include subfolders 
Ruby :: ruby push array 
Ruby :: generate dates using period rails 
Ruby :: rails not_found 
Ruby :: rails g migration foreign key optionnal 
Ruby :: rails has_many through source 2 
Ruby :: rails image 
Ruby :: sequel alter table 
Ruby :: csv parse ruby 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =