【问题标题】:Adding UIActivityIndicator to splashscreen将 UIActivityIndi​​cator 添加到启动画面
【发布时间】:2014-06-13 19:52:11
【问题描述】:

我通过执行 project->General tab-> Launch Images-> 添加了启动画面

从这里我根据尺寸拍了两张照片,效果也很好。

现在我想在上面放一个活动指示器

所以在加载我的数据库和文件之前,应该显示启动画面和指示器。

我能做些什么呢?

我也尝试了一些建议

我确实喜欢这个

[self performSelector:@selector(loadingViewFade) withObject:nil];

  • (void) loadingViewFade

    loadingView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)]; loadingView.image = [UIImage imageNamed:@"splashscreen_640x960"]; [_window addSubview:loadingView]; [_window bringSubviewToFront:loadingView]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:3.0]; [UIView setAnimationDelay:3.0]; [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:_window cache:YES]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)]; 加载视图.alpha = 0.5f; [UIView 提交动画];

    //创建Activity Indicator并将其添加到loadingView UIActivityIndi​​catorView *activityIndi​​cator = [[UIActivityIndi​​catorView alloc] initWithActivityIndi​​catorStyle:UIActivityIndi​​catorViewStyleWhite]; 活动指标.alpha = 1.0; activityIndi​​cator.center = CGPointMake(160, 430); activityIndi​​cator.hidesWhenStopped = NO; UILabel *text = [[UILabel alloc]initWithFrame:CGRectMake(140, 435, 160, 30)]; text.backgroundColor = [UIColor clearColor]; text.textColor = [UIColor whiteColor]; text.font = [UIFont systemFontOfSize:14]; text.text = @"加载中..."; [加载视图添加子视图:文本]; [loadingView addSubview:activityIndi​​cator]; [loadingView addSubview:activityIndi​​cator]; [activityIndi​​cator startAnimating];

(void)startupAnimationDone:(NSString *)animationID 完成:(NSNumber *)完成上下文:(void *)context

[loadingView removeFromSuperview];

再次启动以及指示器不显示,而是加载默认屏幕,直到数据库加载..请帮帮我

【问题讨论】:

    标签: ios splash-screen uiactivityindicatorview


    【解决方案1】:

    项目->常规选项卡-> 启动图像-> 将默认启动画面或加载屏幕添加到您的项目。您不能在默认图像上显示活动指示器。要向活动指示器显示加载消息,您需要添加具有背景图像作为您之前设置的默认图像的启动视图控制器。还有一个活动指示器来显示加载状态。完成数据库和其他内容的加载后,停止动画活动指示器并关闭启动屏幕。

    【讨论】:

    • 所以我必须在数据库加载之前添加启动画面,对吗?我必须在启动画面上添加一个活动指示器。活动指示器应该是splashview的子视图吗?
    • 我怎么知道数据库是否完全加载。因为基于此我必须离开启动视图控制器并导航到主屏幕对吗?
    • 搜索一下 Grand Central Dispatch。这将帮助你
    【解决方案2】:

    我认为您应该创建自己的初始屏幕,并通过编程方式将 UIActivityIndi​​cator 添加到此初始屏幕。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-18
      • 1970-01-01
      相关资源
      最近更新 更多