在我的应用程序中,我用相机拍照后我想导航到
中的另一个viewcontrollerdidFinishPickingMediaWithInfo
现在,我在dismissViewControllerAnimated函数的completition块中执行此操作,但我觉得这不是最优雅的方法。你能告诉我这可以做得更好吗?这是确切的代码
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = info[UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
UIImage *image = [info[UIImagePickerControllerOriginalImage] scaledCopyOfSize:CGSizeMake(175.0f, 175.0f)];
[self dismissViewControllerAnimated:YES completion:^(void){
setVC = [[SetVCr alloc]init];
[[self navigationController]pushViewController:seVC animated:YES];
}];
}
}
答案 0 :(得分:1)
您可以直接从选择器推送新视图控制器
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = info[UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
UIImage *image = [info[UIImagePickerControllerOriginalImage] scaledCopyOfSize:CGSizeMake(175.0f, 175.0f)];
setVC = [[SetVCr alloc]init];
[picker pushViewController:seVC animated:YES];//you can push new view controller directly from the picker
}
}
答案 1 :(得分:0)
我建议将完成块设置为nil,然后在下一行调用'performSegueWithIdentifier'方法,如下所示:
[self performSegueWithIdentifier:@"segueToNewcontroller" sender:self];