您還需要contentSize,contentOffset和zoomScale得到精確的輸出
您都可以存儲到UserDefault並在需要時再恢復
檢查這裏怎麼能與處理NSUserDefaults
https://stackoverflow.com/a/4562488/4601900
NSMutableDictionary *dict = [@{
kZoomLevel : [NSString stringWithFormat:@"%f", self.zoomScale],
kRotationDegree :[NSString stringWithFormat:@"%f", self.rotationAngle],
kScrollViewContentSize : NSStringFromCGSize(self.scrollViewPhoto.contentSize),
kScrollViewContentOffset : NSStringFromCGPoint(self.scrollViewPhoto.contentOffset),
}mutableCopy];
你需要這樣恢復它
if (dictMainData) {
NSString *contentSize = [dictMainData valueForKey:kScrollViewContentSize];
if (contentSize) {
self.contentSize = CGSizeFromString(contentSize);
self.scrollViewPhoto.contentSize = self.contentSize;
}
NSString *contentOffset = [dictMainData valueForKey:kScrollViewContentOffset];
if (contentOffset) {
self.contentOffset = CGPointFromString(contentOffset);
self.scrollViewPhoto.contentOffset = self.contentOffset;
}
NSString *strZoomLevel = [dictMainData valueForKey:kZoomLevel];
if ([strZoomLevel floatValue] > 0) {
self.zoomScale = [strZoomLevel floatValue];
self.viewBase.transform = CGAffineTransformMakeScale(self.zoomScale,[strZoomLevel floatValue]);
CGRect frame = self.viewBase.frame;
frame.origin = CGPointMake(0, 0);
self.viewBase.frame = frame;
}
NSString *strRotationDegree = [dictMainData valueForKey:kRotationDegree];
if ([strRotationDegree floatValue] > 0) {
self.rotationAngle = [strRotationDegree floatValue];
self.imageView.transform = CGAffineTransformMakeRotation(self.rotationAngle * M_PI/180);
//[self rotateTargetPointsAsPerRotationAngle];
}
}
的可能的複製[NSUserDefaults的 - 保存的UIImageView位置](https://stackoverflow.com/questions/17383897/nsuserdefaults-saving-uiimageview-position) – the4kman
你究竟嘗試了什麼? –