我最近檢查項目「演示照片局」發現here。保存多個自定義的UIImageViews
這是將UIImageView添加到添加了UIGestureRecognizers的屏幕的簡單演示...允許用戶操作各種UIImageView。
我加的觀點,像這樣:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
imageview.userInteractionEnabled = YES;
[imageview setImage:image];
UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(scale:)];
[pinchRecognizer setDelegate:self];
[imageview addGestureRecognizer:pinchRecognizer];
UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];
[rotationRecognizer setDelegate:self];
[imageview addGestureRecognizer:rotationRecognizer];
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[panRecognizer setDelegate:self];
[imageview addGestureRecognizer:panRecognizer];
[self.view addSubview:imageview]; }
我甚至可以保存像這樣的觀點:
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSKeyedArchiver archivedDataWithRootObject:imageview] forKey:@"imageViewSaved"];
現在我的問題:下面的方法僅保存最後的ImageView添加到屏幕。任何人都知道如何保存屏幕上的所有圖像...如果用戶添加多個圖像?
你不能只是做一樣的,你已經與第一ImageView的呢?我不太確定,如果我完全理解您的問題,您是否問如何將多個imageView存檔添加到您的視圖? –
我提供的例子允許用戶每次從他們的照片庫中選擇照片時在屏幕上添加一個uiimageview。所有這些圖像瀏覽本質上都是「imageview」(見上面的代碼)。我很難弄清楚如何區分這些不同的圖像視圖。目前它只保存添加的最新視圖...即使其他uiimageviews也在屏幕上。我想我每次選擇一張附加照片時都可以在新的圖像視圖中編碼,但是我必須限制允許添加多少個uiimageviews。 – jccotant