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.

4

2 回答 2

4

RajB - 对于滚动视图的缩放,请执行以下操作:

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

希望这可以帮助!

于 2010-07-13T14:30:00.450 回答
1

您创建一个UIScrollView但从不将其添加到视图层次结构中,因此它永远不会显示。调用[window addSubview:scrollView],然后不要忘记释放它。

如果您在项目中使用 MainWindow.xib,您的窗口是为您创建的,您不需要创建自己的。

使用[[UIScreen mainScreen]而不是CGRect(0, 0, 320, 420)<- 我也相信你的意思是“480”

设置完启动动画后,调用[window addSubview:[mainTabBarController view]]. 即使像前面提到的那样添加了滚动视图,它也会成为最顶层的可见视图。

延迟[window addSubview:[mainTabBarController view]]直到您的飞溅动画完成后。

于 2010-05-21T09:09:00.933 回答