在制作iOS应用程序时,我仍然是一个菜鸟,我不明白为什么会出现某个错误。对于我目前的项目,我试图切换视图,但我无法让它工作,我真的不明白为什么。我按照本教程中的按钮(http://www.youtube.com/watch?v=ph3XhJD8QAI),虽然教程较旧,但它仍然有效。我不得不编辑一些代码以确保它适用于Xcode 5。每当我按下按钮切换视图时,我都会收到一条错误,上面写着“警告:在演示文稿正在进行时,< SeriouslyFunnyView:0xc91a130>上尝试显示< SecondView:0xc918d50>”并且iPhone模拟器中的屏幕变黑了。我也在使用Storyboard,我不确定这是否与情况有关。任何人都可以告诉我我做错了什么吗?如果我需要添加更多代码以便澄清,请告诉我们!在此先感谢您的帮助
以下是我切换视图的按钮的代码
-(IBAction)SwitchView:(id)sender {
SecondView *second = [[SecondView alloc] initWithNibName:nil bundle:nil];
[self presentViewController:second animated:YES completion:NULL];
}
答案 0 :(得分:3)
您必须在呈现另一个视图之前完全解除视图。试试:
[self dismissViewControllerAnimated:YES completion: ^{
SecondView *second =
[[SecondView alloc] initWithStyle:UITableViewStylePlain];
controller.modalTransitionStyle = UITableViewStylePlain;
[self presentViewController:second animated:YES completion:nil];
}];
答案 1 :(得分:0)
评论switchview的主体,并检查是否有任何控制器出现在点击switchview ..这看起来很傻但可能有助于找出哪个控制器正在进行中...我' m也不习惯故事板,所以..希望有所帮助
答案 2 :(得分:0)
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// TODO: make this all threaded?
// crop the image to the bounds provided
img = [info objectForKey:UIImagePickerControllerOriginalImage];
NSLog(@"orig image size: %@", [[NSValue valueWithCGSize:img.size] description]);
// save the image, only if it's a newly taken image:
if ([picker sourceType] == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
}
// self.image_View.image = img;
// self.image_View.contentMode = UIViewContentModeScaleAspectFit;
NSLog(@"Picker has returned");
[self dismissViewControllerAnimated:YES
completion:^{
ModalViewController *sampleView = [[ModalViewController alloc] init];
[self presentModalViewController:sampleView animated:YES];
}];
}