在我的測試應用程序中,我有兩個按鈕(takePhoto1和takePhoto2)和兩個UIImageView(photo1View和photo2View)。第一個按鈕拍攝一張照片並將其顯示在第一張圖像視圖中。第二個按鈕拍攝另一張照片,應該顯示在第二個圖像視圖中。但是,由於某種原因,第二張照片將顯示在photoView1而不是photoView2中。在不同的UIImageView中顯示照片
我還沒有實現任何代碼來保存照片,所以我並不擔心圖片視圖中持續存在的照片。
我需要弄清楚的是如何確定何時拍攝第二張照片,它會顯示在相應的視圖中。這是我到目前爲止:
//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;
}
任何人都知道如何解決這個問題?
謝謝,完美的工作!該示例項目非常有用。乾杯! – narner 2014-09-06 23:18:39