A white screen is displayed instead of my launch screen on my iPad Air when I start my iOS project

Kim Strasser 661 Reputation points
2023-02-05T14:38:53.1466667+00:00

I have a LaunchScreen.storyboard file in my iOS project and it worked a few weeks or months ago. But now only a white screen is displayed instead of my launch screen. In addition, I have the same problem with UIImageView, a white screen is displayed instead of the UIImageView image.

MyViewController.cs:

using UIKit;
using SharedCode;
using Microsoft.Maui.Controls;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Xna.Framework;

namespace MyProjectiOS
{
    public partial class MyViewController : UIViewController
    {
        private UIImageView LogoImage;

        public MyViewController() : base("MyViewController", null)
        {
        }

        public override void ViewDidLoad()
        {
            View = new UIView();
            View.BackgroundColor = UIColor.White;
            base.ViewDidLoad();
            UIView viewbg = new UIView(new CoreGraphics.CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height));
            View.AddSubview(viewbg);

            WeakReferenceMessenger.Default.Register<Game1Message>(this, (r, m) =>
            {
                G_RemoveLogoTestMyView();
            });

            LogoImage = new UIImageView(UIImage.FromBundle("Image"));
            LogoImage.ContentMode = UIViewContentMode.ScaleAspectFit;
            LogoImage.Tag = 1234;
            LogoImage.Frame = new CoreGraphics.CGRect(0, 0, 375, 375);
            viewbg.AddSubview(LogoImage);
            LogoImage.Center = viewbg.Center;
        }

        public void G_RemoveLogoTestMyView()
        {
            //remove image
            var LogoView = View.ViewWithTag(1234);
            if (null != LogoView)
                LogoView.RemoveFromSuperview();
        }

        public override void DidReceiveMemoryWarning()
        {
            base.DidReceiveMemoryWarning();
            // Release any cached data, images, etc that aren't in use.
        }
    }
}

I use .NET 7.0, target iOS version 16.1, minimum iOS version 15.0 and Visual Studio for Mac 17.5 Preview (build 1741).

Why are the launch screen and the UIImageView LogoImage not displayed on my iPad Air?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,936 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,316 questions
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,751 Reputation points Microsoft Vendor
    2023-02-09T02:19:00.1466667+00:00

    Hello,

    There are two issues for you, the first one is that the Launch Screen isn't displayed and you cannot open the storyboard file via VS for Mac, another one is that the image named "Image" is not displayed in your MyViewController.

    For the first Launch Screen issue, you can follow the progress at DC- cannot open a storyboard file in my iOS project in VS for Mac 17.5 Preview
    For the second image issue, you could try to add an image into Resources folder, and set its build action to BundleResource, then display the image on MyViewController.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful