tags:

views:

113

answers:

2

HI, I develop an application in which i want to implement the splash screen, on that splash screen i want to bind the scrollView and UIImage. My code as follow,

-(void)splashAnimation{
    window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 420)];
    //scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    scrollView = [[UIScrollView alloc] initWithFrame:[window bounds]];
    scrollView.pagingEnabled = NO;
    scrollView.bounces = NO;

    UIImage *image = [UIImage imageNamed:@"splash.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.userInteractionEnabled = NO;  

    [scrollView addSubview:imageView];
    [scrollView setDelegate:self];
    //[scrollView release];


}

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    [self splashAnimation];
    [self initControllers];
    [window addSubview:[mainTabBarController view]];
    [window makeKeyAndVisible];
}

On my given code the one blank window comes up and stay on. I want to on that blank screen bind my splash.png.

*The Above problem is solved* My current code is

scrollView.pagingEnabled = NO; scrollView.bounces = NO;

UIImage *image = [UIImage imageNamed:@"splash.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.userInteractionEnabled = NO;  
[scrollView addSubview:imageView];

scrollView.maximumZoomScale = 4.0f;
scrollView.minimumZoomScale = 1.0f;

CGRect rect = CGRectMake(119, 42, 208, 166);

[scrollView zoomToRect:rect animated:YES];
[scrollView setDelegate:self];
[window addSubview:scrollView];
[window makeKeyAndVisible];

i want to zoom the particular part of scrollView.

A: 

You create a UIScrollView but never add it to the view hierarchy, therefore it will never get displayed. Call [window addSubview:scrollView], and then don't forget to release it.

If you are using a MainWindow.xib in your project, your window is created for you, you do not need to create your own.

Use [[UIScreen mainScreen] instead of CGRect(0, 0, 320, 420) <- I also believe you meant "480"

After setting up your splash animation, you call [window addSubview:[mainTabBarController view]]. Even after adding your scrollview as previously mentioned, this will then become the topmost and therefore visible view.

Delay the [window addSubview:[mainTabBarController view]] until after your splash animation completes.

Kenny
@Kenny,Thanks. Your answer is really helpful and working for me. It solving my problem.Please, help me how i zooming the particular part of UIScrollView(scroll content UIImage).I want to zoom CGRect(119, 42, 208, 166)of scrollView, can i? My current code edited in main question.
RRB
A: 

RajB - for your zooming of the scrollView do this:

    CGRect zoomRect=CGRectMaket(119, 42, 208, 166);
[scrollView zoomToRect:zoomRect animated:YES];

Hope this helps!

ayreguitar