应用程序启动时的 UIActivityIndi​​cator

发布于 2024-11-27 16:36:07 字数 213 浏览 1 评论 0原文

我已经搜索过,但没有找到我想要的东西。我有一个 UITabBar 应用程序,在第一个视图中,它从网络加载大量数据。这可能需要几秒钟的时间,尤其是在连接到边缘网络时。

我有一个显示徽标等的启动屏幕,但我想添加一个活动指示器以向用户显示实际正在发生的事情。

我怎样才能实现这个目标?我发现的帖子只在选项卡之间切换时考虑 ActivityIndi​​cators。

谢谢

I have searched but not found exactly what I was looking for. I have a UITabBar application that, in the first view, loads a large set of data from the web. This might take several seconds, especially when connected to an Edge network.

I have a startup screen showing a logo etc., but I would like to add an activity indicator to show the user that something is actually going on.

How can I achieve this? The posts I have found do only regard ActivityIndicators while switching between tabs.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩心不撩汉 2024-12-04 16:36:07

如果加载数据需要很长时间,您可以使用另一个视图控制器作为 rootViewController,只需具有启动屏幕(具有在下载数据之前可以显示的图像或视图的屏幕)和活动指示器,当您下载完成时,删除temprootViewcontroller 从窗口并将原始控制器添加到窗口。

编辑

    //To show custom Splash screen do something like in
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

SplashScreenVC *splashScreenVC = [[SplashScreenVC alloc] initWithNibName:@"SplashScreenVC" bundle:nil];
    self.window.rootViewController = splashScreenVC;
    [self.window makeKeyAndVisible];

//And when your data finishes downloading you can write following there to show your tabBar.

AppDelegate*delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
delegate.window.rootViewController = delegate.tabBarController;
[delegate.window makeKeyAndVisible];

//If you want to simulate downloading and want to sleep the device you can try this in SplashScreenVC

-(void)viewDidAppear:(BOOL)animated{
        [super viewDidAppear:animated];
        [self performSelector:@selector(gotosleep) withObject:nil afterDelay:1.0];
    }
    -(void)gotosleep{
        sleep(5);
        AppDelegate*delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
        delegate.window.rootViewController = delegate.tabBarController;
        [delegate.window makeKeyAndVisible];
    }

If the loading of data takes much time you can take another view controller as your rootViewController just having the Splashscreen (The screen having the image or view that you can display till the data is being downloaded) and activity indicator and when your download completes remove the temprootViewcontroller from the window and add your original controller to the window.

Edit

    //To show custom Splash screen do something like in
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

SplashScreenVC *splashScreenVC = [[SplashScreenVC alloc] initWithNibName:@"SplashScreenVC" bundle:nil];
    self.window.rootViewController = splashScreenVC;
    [self.window makeKeyAndVisible];

//And when your data finishes downloading you can write following there to show your tabBar.

AppDelegate*delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
delegate.window.rootViewController = delegate.tabBarController;
[delegate.window makeKeyAndVisible];

//If you want to simulate downloading and want to sleep the device you can try this in SplashScreenVC

-(void)viewDidAppear:(BOOL)animated{
        [super viewDidAppear:animated];
        [self performSelector:@selector(gotosleep) withObject:nil afterDelay:1.0];
    }
    -(void)gotosleep{
        sleep(5);
        AppDelegate*delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
        delegate.window.rootViewController = delegate.tabBarController;
        [delegate.window makeKeyAndVisible];
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文