2010-05-15 2 views

답변

1

먼저, iPhone OS의 스프링 보드가로드 시간에 대해 다소 까다 롭다는 것을 알아야합니다. 당신은 응용 프로그램의 로딩 과정에서 절대 절대로 잠들지 말아야합니다. 응용 프로그램이 실행되는 데 Springboard가 감지하면 응용 프로그램이 "종료 시간 내에 실행되지 못했습니다" 크래시 로그에서 종료됩니다.

두 번째로, 내가 아는 한, 응용 프로그램을 시작하는 데 걸리는 시간을 측정하는 방법은 없습니다. 사용자가 도약판에서 응용 프로그램 아이콘을 두드리면 iPhone OS가 응용 프로그램에 좋은 정보를 제공하지 않을 때 여러 가지 일이 발생합니다.

applicationDidFinishLaunching:매우 가벼운인지 확인하고 "가짜"Default.png 오버레이를 만들 수 있습니다. applicationDidFinishLaunching: 메서드를 트리밍하여 가장 중요한 작업 만 수행하고 백그라운드에서 시간이 많이 걸리는 작업을 수행하면 Default.png 오버레이가 다른 하드웨어에 대략 같은 시간으로 표시되도록 할 수 있습니다.

- (void)applicationDidFinishLaunching:(UIApplication *)application { 
    // Create the image view posing with default.png on top of the application 
    UIImageView *defaultPNG = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]]; 
    // Add the image view top-most in the window 
    [window addSubview:defaultPNG]; 

    [window makeKeyAndVisible]; 

    // Begin doing the time consuming stuff in the background 
    [self performSelectorInBackground:@selector(loadStuff) withObject:nil]; 

    // Remove the default.png after 3 seconds 
    [self performSelector:@selector(removeDefaultPNG:) withObject:defaultPNG afterDelay:3.0f]; 
} 

- (void)removeDefaultPNG:(UIImageView *)defaultPNG { 
    // We're now assuming that the application is loaded underneath the defaultPNG overlay 
    // This might not be the case, so you can also check here to see if it's ok to remove the overlay 
    [defaultPNG removeFromSuperview]; 
    [defaultPNG release]; 
} 

당신이 loadStuff 방법에 더 뷰 (뷰 컨트롤러 등)을 추가 할 경우, 당신은 defaultPNG 오버레이 아래를 삽입해야합니다. 다른 스레드에서 이러한 작업을 수행하면 발생할 수있는 문제점에 대해서도 알고 있어야합니다. 문제가 발생하면 performSelectorOnMainThread:withObject:waitUntilDone:을 사용할 수 있습니다.

+0

안녕하십니까, 고마워요, 이것에 대해 감사합니다. 우선 잘 읽어야하지만, 곧 다시 돌아올 것입니다. – iFloh

관련 문제