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.
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 ofCGRect(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.RajB - for your zooming of the scrollView do this:
Hope this helps!