开发者

progressView doesn't work

i want to show a progressView when the app is launching (with the splash screen) so, in the appDelegate .h file i declared a progressView :

UIProgressView *progView;

and in the appDelegate .m file i did this :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    sleep(1);



    progView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressVi开发者_运维问答ewStyleBar];
    progView.progress = 0.75f;


// the rest..
}

i didn't see the progress bar in the splash screen, help please, thx in advance :)


You cannot influence the splash screen itself, it's only a static image.

What you can do however is to let your app load until you get the delegate message, then fire up some basic UI which shows your progress view and then do some heavy startup process in a background thread, updating your progress bar accordingly. When the thread has finished its work, call back to the main thread to start the real application.

Edit: Updated my answer to clarify some things

The application startup in iOS happens basically in 2 phases.

  1. The operating system launches your application, the app sets up basic stuff, starts the run loop, etc. During this time the splash screen is shown. During this phase the application is not under the control of the programmer.
  2. -application:didFinishLaunchingWithOptions is called. In this method you as a programmer may do some startup tasks, such as loading the database, connecting to some service, etc. During this phase you can influence the user interface and also show for example a progress bar. If you need to do this, create a background thread and do the setup work there.

Note: It does not work if you just put a progress bar on the UI and then do some stuff in the -application:didFinishLaunchingWithOptions: method, since the UI is not shown until after this method has returned. That's why you need to do the setup in a background thread.


is that all the code for progView? Cuz you haven't added it as a subview to anything, so how would you be able to see it? You need something like:

[splashView addSubview:progView];

frenetisch gave some reasonable explanation of the startup process of an IOS app, but it sounds like you need to do some basic investigation into this. It generally takes very little time before your didFinishLaunchingWithOptions is called and you can show your first view. But what things do you then need to do before your app is actually usable? You want to show a progress view so there must be SOMETHING that you plan to do that takes some time. It's while THAT is going on you need to show the progress view and somehow update it's progress.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜