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];

如果您使用动画呈现模态视图控制器,请将其释放到完整的块中,您可以尝试:

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

一旦你选择图像,它将移动到发送视图控制器

- (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];

}


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

在这里,你将这个YES改为NO。 即,无需动画即可解除模态视图。

链接地址: http://www.djcxy.com/p/68375.html

上一篇: iOS: how to change between views after picking a photos?

下一篇: UIImagePickerController releases my views and controllers