我有2vcs。主要的vc是* ViewController和其他*问题。启动按钮可以很好地将我带到Questions.vc,但当我尝试从Questions.vc返回ViewController.vc时应用程序崩溃了。 Quit按钮在Questions.H中声明,按钮被链接起来,但是一旦我点击并按下退出按钮,应用程序就会崩溃。
打开所有异常断点后。它显示10个断点,其中3个禁用。这些是代码行: 问题.H所有这三行
`
-(IBAction)OphthalmicInstruments:(id)sender;
-(IBAction)Lenses:(id)sender;
-(IBAction)Transposition:(id)sender;
`
Questions.M(蓝色箭头指向空格b / t这两行 `
-(IBAction)OphthalmicInstruments:(id)sender{
Cat1.hidden = YES;
` Question.M蓝线箭头案例2答案3&案例3错误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 _____."];
`
答案 0 :(得分:2)
我创造了一些非常相似的东西并遇到了同样的问题。我所做的是改变了在VC之间来回传递的代码。
因此,我将其更改为 首先是我的ViewController.m中的主页Viewcontroller to Questions
- (IBAction为)StartQuiz:(ID)发送方{
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];
}
答案 1 :(得分:0)
1)这与xcode
有什么关系?答:没什么所以请不要使用那个标签。
2)您的应用不会在return UIApplicationMain(...
时崩溃,因为它确实会导致您无法抓住error
/ exception
。要找出它的破坏位置,您需要添加Catch all exceptions
。
您可以通过转到xcode中导航控制器的Exceptions
部分来执行此操作。
在此处导航后,您会注意到窗口左下角有+
。选择此项,这样就会显示另一个带有两个选项的小窗口
您需要选择Add Exception Breakpoint
选择此项后,您将看到一个新窗口
您需要做的就是保留默认设置,然后点击Done
,除非您想要使用它们。这将使得当抛出异常时它应该引起它崩溃的线或一般区域,以便更容易识别问题。
这可能无法解决您的问题,但距离解决问题又近了一步。当你得到错误的一般区域时,请发表评论,我会更新我的答案,包括如何解决它,如果可以的话。