2011-07-08 116 views
0

我正在寫一個應用程序,用戶可以在庫中選擇一張照片,發送到服務器。 這是我的代碼iOS:如何在拍攝照片後在視圖之間切換?

 
-(IBAction)btnTakePictureClicked { 
    UIImagePickerController* picker = [[UIImagePickerController alloc] init]; 
    picker.delegate=self; 
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
    [self presentModalViewController:picker animated:YES]; 
    [picker release]; 
} 

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{ 
    [picker.parentViewController dismissModalViewControllerAnimated:YES]; 
    self.imgTemp = image; 

// Where should these lines be? 
    Send* send = [[Send alloc] initWithNibName:@"Send Email" bundle:nil]; 
    [self presentModalViewController:send animated:YES]; 
    [send release]; 
} 

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { 
    [picker.parentViewController dismissModalViewControllerAnimated:YES]; 
} 

我預計,挑選照片後,它將改變發送頁面。但是,它仍然回到主頁。

這些行應該在哪裏?

 
Send* send = [[Send alloc] initWithNibName:@"Send Email" bundle:nil]; 
    [self presentModalViewController:send animated:YES]; 
    [send release]; 

回答

0

一旦選擇了圖像,它移動到發送視圖控制器

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:UIImage *)image editingInfo:(NSDictionary *)editingInfo{ 
self.imgTemp = image; 
Send* send = [[Send alloc] initWithNibName:@"Send Email" bundle:nil]; 
[self presentModalViewController:send animated:YES]; 
[send release]; 

}

+0

它仍然回到頁面包含按鈕,從庫中加載。無論如何,感謝您的幫助。 –

0
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{ 
    [picker.parentViewController dismissModalViewControllerAnimated:YES]; 
    self.imgTemp = image; 
..... 

這裏你讓說YES爲NO。即,無需動畫即可解除模態視圖。

+0

對不起戈馬蒂。這不是我要問的。 –

1

如果出現帶有動畫的模態視圖控制器,釋放它在完工塊,你可以嘗試:

Send* send = [[Send alloc] initWithNibName:@"Send Email" bundle:nil]; 
    [self presentViewController:send animated:YES completion:^{ 
     [send release]; 
    }]; 
相關問題