how to load application main page after custom lunch screen viewcontroller

Hi All,
how to load application main page after custom lunch screen viewcontroller

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();

        Window = new UIWindow(UIScreen.MainScreen.Bounds);

        var controller = new ViewController();
        controller.View.BackgroundColor = UIColor.White;

        Window.RootViewController = controller;

        // make the window visible
        Window.MakeKeyAndVisible();
      System.Threading.Thread.Sleep(15000);*///will wait for 4 seconds
       LoadApplication(new App());
        return base.FinishedLaunching(app, options);

    }

if i do like this immediately launching application without visibiling my custom launch screen uicontroller even if i put thread.sleep also it is loading application without displaying launchscreen controller .suppose if remove LoadApplication(new App()); then my launchcontroller is displaying.suppose if i remove LoadApplication(new App()); then where i need to call this(i need to navigate to application after launch screen).

  please post here if any one knows about this

Best Answer

Answers

  • Sumit_SharmaSumit_Sharma USMember ✭✭✭

    You can create your own LaunchScreen in XF.iOS project then you need to set it on your info.plist like this

  • divyagarimelladivyagarimella Member ✭✭

    i am creating custom launchscreen (with animation) that's why i created custom uicontroller for launch screen.if it is normal launchscreen then we can do like above screenshot

  • Sumit_SharmaSumit_Sharma USMember ✭✭✭

    That's what I am saying

    Create a StoryBoard and set it like this

  • divyagarimelladivyagarimella Member ✭✭

    if we do like this do we need to call it externally like
    Window = new UIWindow(UIScreen.MainScreen.Bounds);

        var controller = new ViewController();
        controller.View.BackgroundColor = UIColor.White;
    
        Window.RootViewController = controller;
    
        // make the window visible
        Window.MakeKeyAndVisible();
    
  • Sumit_SharmaSumit_Sharma USMember ✭✭✭
    I don't think so, because when you set the launch screen it will be called first before your LoadApplication in Appdelegate will be called. In your storyboard you can add a cs file as well, and try animating, delaying thread there.
  • divyagarimelladivyagarimella Member ✭✭

    Thank you so much @LandLu Its very helpful
    and one more thing my gif image is not animating here its only showing static image instead of gif.if you have any idea please tell me
    logoGifImageView = new UIImageView(UIImage.FromBundle("launchscreen.gif"));
    animation.logoGifImageView.AnimationDuration = 1;
    animation.logoGifImageView.AnimationRepeatCount = 0;

            animation.logoGifImageView.StartAnimating();
    
  • divyagarimelladivyagarimella Member ✭✭

    and i tried like this also but it's also showing all static images instead of gif images
    var array = new UIImage[] {
    UIImage.FromBundle ("home.gif")
    , UIImage.FromBundle ("outofhour.gif")
    , UIImage.FromBundle ("quotes.gif")
    , UIImage.FromBundle ("schedule.gif")
    };
    animation.logoGifImageView.AnimationImages = array;
    animation.logoGifImageView.AnimationDuration = 1;
    animation.logoGifImageView.AnimationRepeatCount = 0;
    animation.logoGifImageView.StartAnimating();

  • LandLuLandLu Member, Xamarin Team Xamurai

    Please share your sample if possible, as it could be your gif files' issue. Without them, I can't reproduce your issues on my side.

  • divyagarimelladivyagarimella Member ✭✭

    sorry i forgot to tell you my gif image is in Resources folder of xamarin ios project.i think its taking path that's why its showing static image

  • LandLuLandLu Member, Xamarin Team Xamurai

    Moreover, UIImageView can play a set of static images so that it looks like a gif file. You can try this to play a gif file directly:
    https://github.com/xamarin/ios-samples/blob/master/ios11/SamplePhotoApp/Shared/AnimatedImageView.cs

  • divyagarimelladivyagarimella Member ✭✭

    hi @LandLu Please find my attached sample project

  • AhmedHasanAhmedHasan USMember ✭✭

    @divyagarimella have you find the solution ? I am stuck here as well

  • AhmedHasanAhmedHasan USMember ✭✭

    Hey Thanks @LandLu I got the idea from your answer, solved my issue, In my case I don't need this

    MessagingCenter.Subscribe<object, object>(this, "ShowMainScreen", (sender, args) =>
    {
    LoadApplication(new App());
    base.FinishedLaunching(app, options);
    });

    exactly but I got the event where I can call LoadApplication.

    Thanks @divyagarimella to you as well.

Sign In or Register to comment.