我試圖讓我的圖像爲pan
和zoomable
,但我似乎無法讓它工作。使用UIScrollView滾動UIImage
這裏是我的註釋代碼>創建UIScrollView
>創建PFImageView
(UIImage
)>添加圖片到UIScrollView
>獲取&顯示圖像。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"%@",_courseObject); //checking object has loaded
UIScrollView *scrollView = [[UIScrollView alloc] init];
scrollView.frame = self.view.bounds; //scroll view occupies full parent view!
scrollView.contentSize = CGSizeMake(400, 800); //scroll view size
scrollView.showsVerticalScrollIndicator = YES; //to hide scroll indicators!
scrollView.showsHorizontalScrollIndicator = YES; //by default, it shows!
scrollView.scrollEnabled = YES; //say "NO" to disable scroll
[self.view addSubview:scrollView]; //adding to parent view!
PFImageView *mapImage = [[PFImageView alloc] init]; //create imageview
mapImage.frame = self.navigationController.view.frame; //set image boundaries to fill nav frame(!)
mapImage.image = [UIImage imageNamed:@"loading"]; //placeholder image
mapImage.file = (PFFile *)[_courseObject objectForKey:@"file"]; //retrieve the map image
[scrollView addSubview:mapImage]; //add the mapImage to scrollView
[mapImage loadInBackground]; //retrieve image and add
}