0
我有一個子類UIView
,我可以滾動但不縮放。我使用autolayout,所以想知道IOS6中是否有任何改變。特別是何時實施scrollViewWillBeginZooming
和scrollViewDidEndZooming
方法。我的代碼看起來像UIScrollView不會縮放
- (void)viewDidLoad
{
[super viewDidLoad];
self.ringSet2 = [[RingView alloc] initWithFrame:CGRectMake(0, 0, 800, 800)];
[self.ringSet2 setDefaults];
/// ... more setup for other views but only ringSet2 is scrolled.
self.scrollview1.delegate=self;
self.scrollview1.scrollEnabled=YES;
self.scrollview1.contentSize=self.ringSet2.bounds.size
self.scrollview1.minimumZoomScale=0.2;
self.scrollview1.maximumZoomScale=5.0;
self.ringSet2.userInteractionEnabled=YES;
// ... needed elsewhere so other views can pick up their dimensionts
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
/// ... code for additional views
[self.scrollview1 zoomToRect:CGRectMake(0, 0, 200, 200) animated:YES];
[self.scrollview1 addSubview:self.ringSet2];
}
與
-(UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return self.ringSet2;
}
和scrollViewWillBeginZooming
等實現的只是跟蹤發生了什麼。有趣的是, viewForZoomingInScrollView
似乎只被調用一次,因爲scrollViewDidEndZooming
的比例值剛好低於1,但scrollViewWillBeginZooming
永遠不會被調用。屬性ringSet2被定義爲
@property (strong, nonatomic) IBOutlet RingView *ringSet2;
因爲視圖不會出現,如果它被定義爲弱。
有意義的是視圖不會出現:您負責保留頂層對象。 – CodaFi