0
我在iPhone上使用UIScrollView,我希望能夠放大UIView。製作UIView可縮放
我的UIView是mauiscrollview的子視圖。如果我回到來看,當我試圖放大,我認爲舉動,但不變焦:
- (void)viewDidLoad {
[super viewDidLoad];
//mon label peut prendre la valeur de mon menu
[monLabel setText:monMenu];
CGRect frame = CGRectMake(1, 1, 320, 480); // Replacing with your dimensions
maVue = [[UIView alloc] initWithFrame:frame];
maVue.userInteractionEnabled = YES;
scrollView.contentSize = CGSizeMake(320, 480);
scrollView.bounces = YES;
//scrollView.bouncesZoom = YES;
scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scrollView.scrollEnabled = YES;
//scrollView.minimumZoomScale = 1.0;
//scrollView.maximumZoomScale = 5.0;
scrollView.delegate = self;
[scrollView addSubview:maVue];
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView
*)scrollView{ return maVue; }
如果我代替我的看法由標籤爲例:
- (void)viewDidLoad {
[super viewDidLoad];
//mon label peut prendre la valeur de mon menu
[monLabel setText:monMenu];
CGRect frame = CGRectMake(1, 1, 320, 480); // Replacing with your dimensions
maVue = [[UIView alloc] initWithFrame:frame];
maVue.userInteractionEnabled = YES;
scrollView.contentSize = CGSizeMake(320, 480);
scrollView.bounces = YES;
//scrollView.bouncesZoom = YES;
scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scrollView.scrollEnabled = YES;
//scrollView.minimumZoomScale = 1.0;
//scrollView.maximumZoomScale = 5.0;
scrollView.delegate = self;
[scrollView addSubview:monLabel];
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView
*)scrollView{ return monLabel; }
變焦效果很好。我的標籤被放大了。
你知道爲什麼它可以用於標籤,但不適用於UIView嗎?
感謝
你
我評論了初始化minimumZoomScale和maximumZoomScale的代碼,我用IB初始化了。 – amau96 2010-12-22 20:53:35