0

我有一个2vcs。主要 vc 是 *ViewController 和其他 *Questions。开始按钮在将我带到 Questions.vc 时效果很好,但是当我尝试从 Questions.vc 返回 ViewController.vc 时应用程序崩溃。Quit 按钮在 Questions.H 中声明,并且该按钮已链接,但是一旦我 b&r 并点击退出按钮,应用程序就会崩溃。

打开所有异常断点后。它显示了 10 个断点,其中 3 个被禁用。这些是代码行: Questions.H 所有这三行

`

-(IBAction)OphthalmicInstruments:(id)sender;

-(IBAction)Lenses:(id)sender;

-(IBAction)Transposition:(id)sender;

`

Questions.M(蓝色箭头指向空格b/t这两行`

-(IBAction)OphthalmicInstruments:(id)sender{

    Cat1.hidden = YES;

` Questions.M Lines with blue arrow Case 2 Answer 3 & Case 3 Wrong 4

`

      case 2:
            Question.text = [NSString stringWithFormat:@"A tonometer measures:"];
            Right3.hidden = NO;
            Wrong2.hidden = NO;
            Wrong3.hidden = NO;
            Wrong4.hidden = NO;
            Answer1.text = [NSString stringWithFormat:@"Interpupillary distance"];
            Answer2.text = [NSString stringWithFormat:@"Vertex distance"];
            Answer3.text = [NSString stringWithFormat:@"Intraocular pressure"];
            Answer4.text = [NSString stringWithFormat:@"Basecurve"];
            break;
        case 3: 
            Question.text = [NSString stringWithFormat:@"A lens clock measures:"];
            Right4.hidden = NO;
            Wrong2.hidden = NO;
            Wrong3.hidden = NO;
            Wrong4.hidden = NO;
            Answer1.text = [NSString stringWithFormat:@"Interpupillary distance"];
            Answer2.text = [NSString stringWithFormat:@"Vertex distance"];
            Answer3.text = [NSString stringWithFormat:@"Intraocular pressure"];
            Answer4.text = [NSString stringWithFormat:@"Basecurve"];
            break;

` Questions.M 行:break & case 8 行都有蓝色箭头

`

        case 7:
        Question.text = [NSString stringWithFormat:@"The power of a lens is measured in    
_____."];
        Right4.hidden = NO;
        Wrong2.hidden = NO;
        Wrong3.hidden = NO;
        Wrong4.hidden = NO;
        Answer1.text = [NSString stringWithFormat:@"Millimeters"];
        Answer2.text = [NSString stringWithFormat:@"Inches"];
        Answer3.text = [NSString stringWithFormat:@"Nanometers"];
        Answer4.text = [NSString stringWithFormat:@"Diopters"];
        break;
    case 8:
        Question.text = [NSString stringWithFormat:@"A lens with a power of 1 Diopter has a focal length of _____."];

`

4

2 回答 2

2

我正在创建一些非常相似的东西并遇到了同样的问题。我所做的是更改了在 VC 之间来回切换的代码。

所以对于我来说,我将其更改为 First is my main page Viewcontroller to Questions in my ViewController.m

-(IBAction)StartQuiz:(id)sender{

Questions *MenuToQuestions = [[Questions alloc] initWithNibName:nil bundle:nil];
MenuToQuestions.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:MenuToQuestions animated:YES completion:nil];

}

现在这是我的 Questions.m 中的内容

-(IBAction)返回:(id)发件人{

[self dismissViewControllerAnimated:NO completion:nil];

}

于 2013-07-30T14:34:34.520 回答
0

1)这有什么关系xcode?回答:没有所以请不要使用那个标签。

2)您的应用程序不会崩溃,return UIApplicationMain(...因为它说它确实会导致您没有捕获error/ exception。要找出它在哪里中断,您需要添加一个Catch all exceptions.

您可以通过转到Exceptionsxcode 中的导航控制器部分来执行此操作。

xcode 异常窗口

导航到此处后,您会注意到+窗口左下方的 a。选择这个,它会弹出另一个带有两个选项的小窗口

例外选项

您将需要选择Add Exception Breakpoint

一旦你选择了这个,你会得到一个新的窗口

所有例外

您需要做的就是保留默认设置并单击Done,除非您想使用它们。这将使得当异常被抛出时,它应该在它崩溃的行或一般区域,从而更容易识别问题。

这可能无法解决您的问题,但距离解决问题更近了一步。当您得到错误的一般区域时,请发表评论,如果可以的话,我会更新我的答案以包括如何解决它。

于 2013-07-01T12:26:41.397 回答