繁体   English   中英

iOS:挑选照片后如何在视图之间切换?

[英]iOS: how to change between views after picking a photos?

我正在编写一个应用程序,用户可以在库中选择一张照片,发送到服务器。 这是我的代码

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

如果您呈现模态视图 controller 和 animation,在完成的块中释放它,您可以尝试:

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

选择图像后,它将移动以发送查看 controller

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

在这里,你说“是”对“否”。 即,关闭没有 animation 的模态视图。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM