gpt4 book ai didi

iphone - 如何关闭相机并导航到 Root View Controller ?

转载 作者:行者123 更新时间:2023-12-03 19:56:27 26 4
gpt4 key购买 nike

我创建了 3 个 View 。第一个 View 是主页,第二个是库存,第三个是覆盖 View 。现在,我使用 PushViewController 从主屏幕导航到库存 View 屏幕。在库存 View 中,我有一个捕获按钮。捕获按钮将在叠加 View 上打开相机。现在的问题是,叠加 View 中有一个名为后退按钮的按钮,当我单击此按钮时,我想导航到主屏幕,但为此我需要首先关闭相机。这怎么可能?

list View 中的捕获按钮

   -(IBAction) btnCapture:(id) sender
{
@try
{
[self showImagePicker:UIImagePickerControllerSourceTypeCamera];
}
@catch (NSException *exception)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Camera" message:@"Camera is not available " delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
}

在OverlayView后退按钮事件中:

    -(IBAction)btnBack:(id)sender
{
app.navcntr=1;
[self.delegate didFinishWithCamera];
[self dismissModalViewControllerAnimated:YES];
}

在库存 View 中,viewWillAppear

   -(void) viewWillAppear:(BOOL)animated
{
if(app.navcntr ==1)
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
app.navcntr=0;
}

问题是它正在导航到主屏幕,但应用程序崩溃了。怎么解决?

谢谢。 enter image description here

最佳答案

我认为您试图两次关闭相机 View 。我的意思是 didFinishWithCamera 方法将忽略它。删除行 [selfmissModalViewControllerAnimated:YES];

-(IBAction)btnBack:(id)sender
{
app.navcntr=1;
[self.delegate didFinishWithCamera];
}

已编辑

当您不在屏幕上时(“将出现”),您不应该执行动画。

viewDidAppear 中编写代码,例如

-(void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];

if(app.navcntr ==1)
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
app.navcntr=0;
}

关于iphone - 如何关闭相机并导航到 Root View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9987879/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com