How to increase a certain part of UIScrollView?

HI, I am developing an application in which I want to implement a screensaver, on this screensaver I want to bind scrollView and UIImage. My code is as follows

-(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]; } 

In my given code, one empty window appears and continues. I want my splash.png to communicate on this blank screen.

**** The problem above has been resolved **** My current code

  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 increase the specific part of scrollView.

+2
source share
2 answers

RajB - To scale scrollView, do the following:

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

Hope this helps!

+4
source

You create a UIScrollView , but you never add it to the view hierarchy, so it will never be displayed. Call [window addSubview:scrollView] and then remember to release it.

If you use 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 think you meant "480"

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

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

+1
source

All Articles