私のテスト アプリには、2 つのボタン (takePhoto1 と takePhoto2) と 2 つの UIImageView (photo1View と photo2View) があります。最初のボタンは写真を撮り、それを最初の画像ビューに表示します。2 番目のボタンは別の写真を撮り、それを 2 番目の画像ビューに表示することになっています。しかし、なぜか2枚目の写真がphotoView2ではなくphotoView1に表示されてしまいます。
写真を保存するためのコードはまだ実装していないので、画像ビューに写真が残っていることを心配する必要はありません。
私が理解する必要があるのは、2 番目の写真が撮影されたときに適切なビューで表示されるようにする方法です。これが私がこれまでに持っているものです:
//Take photo1 and display in top image view
- (void)takePhoto1;
{
[self dismissViewControllerAnimated:YES completion:NULL];
if ([self.capturedImages count] > 0)
{
if ([self.capturedImages count] == 1)
{
// Camera took a single picture.
[self.photo1View setImage:[self.capturedImages objectAtIndex:0]];
}
// To be ready to start again, clear the captured images array.
[self.capturedImages removeAllObjects];
}
self.imagePickerController = nil;
}
//Take photo2 and display in bottom image view
- (void)takePhoto2;
{
[self dismissViewControllerAnimated:YES completion:NULL];
if ([self.capturedImages count] > 0)
{
if ([self.capturedImages count] == 1)
{
// Camera took a single picture.
[self.photo2View setImage:[self.capturedImages objectAtIndex:1]];
}
// To be ready to start again, clear the captured images array.
[self.capturedImages removeAllObjects];
}
self.imagePickerController = nil;
}
誰でもこれを修正する方法を知っていますか?