HI, 我開發了一個應用程序,在該應用程序中我想實現初始屏幕,在想要綁定scrollView和UIImage的初始屏幕上。我的代碼如下,如何縮放UIScrollView的特定部分?
-(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];
}
在我給定的代碼上出現一個空白窗口並保持不變。 我想在那個黑屏上綁定我的splash.png。
****上面的問題就解決了**** 我當前的代碼是
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];
我想放大滾動視圖的特定部分。
謝謝。你的回答非常有幫助,爲我工作。它解決了我的問題。 請幫助我如何縮放UIScrollView的特定部分(滾動內容UIImage)。我想放大scrollView的CGRect(119,42,208,166),我可以嗎? 我在主要問題中編輯的當前代碼。 – Tirth 2010-05-21 09:41:51