gpt4 book ai didi

更改 View 时 iOS 应用程序崩溃

转载 作者:行者123 更新时间:2023-11-29 01:16:53 25 4
gpt4 key购买 nike

我正在构建一个有很多 View 的应用程序。有一次,按下按钮后, View 从一个 View 变回初始 View Controller 。初始 View Controller 只有在创建新类时添加的默认代码,它唯一的用途是保存用于切换到其他 View 的按钮。带有按钮的 View 有一个文本字段、一个“退出”按钮和几个标签。如果我在 未触及 textField 的情况下按下“退出”按钮,一切顺利,我将返回到原始 View Controller ,在那里我可以继续。但是,如果我决定在 textField 上编辑(甚至只是打开键盘),然后按下退出按钮,应用程序就会崩溃,出现 sigabrt 错误。这是我得到的错误代码。

2016-01-28 17:16:59.666 AutoTutor[64646:2461958] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ATPractice answerBox:]: unrecognized selector sent to instance 0x7fb58855d1e0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000104579e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000103ff2deb objc_exception_throw + 48
2 CoreFoundation 0x000000010458248d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001044cf90a ___forwarding___ + 970
4 CoreFoundation 0x00000001044cf4b8 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000104928194 -[UIApplication sendAction:to:from:forEvent:] + 92
6 UIKit 0x0000000104a976fc -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x0000000104a979c8 -[UIControl _sendActionsForEvents:withEvent:] + 311
8 UIKit 0x00000001052ff506 -[UITextField _resignFirstResponder] + 298
9 UIKit 0x0000000104b346ea -[UIResponder _finishResignFirstResponder] + 292
10 UIKit 0x00000001052ff330 -[UITextField _finishResignFirstResponder] + 49
11 UIKit 0x0000000104b34799 -[UIResponder resignFirstResponder] + 140
12 UIKit 0x00000001052ff1fd -[UITextField resignFirstResponder] + 136
13 UIKit 0x00000001049c9605 -[UIView(Hierarchy) _removeFirstResponderFromSubtree] + 161
14 UIKit 0x00000001049c9b32 __UIViewWillBeRemovedFromSuperview + 71
15 UIKit 0x00000001049c9950 -[UIView(Hierarchy) removeFromSuperview] + 99
16 UIKit 0x0000000104a93493 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke596 + 739
17 UIKit 0x0000000104a8d756 -[UIPresentationController transitionDidFinish:] + 111
18 UIKit 0x0000000104c62e0b -[_UICurrentContextPresentationController transitionDidFinish:] + 42
19 UIKit 0x0000000104a91159 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 183
20 UIKit 0x000000010532cd20 -[_UIViewControllerTransitionContext completeTransition:] + 101
21 UIKit 0x0000000104a8a90f -[UITransitionView notifyDidCompleteTransition:] + 252
22 UIKit 0x0000000104a8a620 -[UITransitionView _didCompleteTransition:] + 1344
23 UIKit 0x0000000104a8cd8c -[UITransitionView _transitionDidStop:finished:] + 104
24 UIKit 0x00000001049b02af -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 241
25 UIKit 0x00000001049b065e -[UIViewAnimationState animationDidStop:finished:] + 80
26 QuartzCore 0x0000000107370fa0 _ZN2CA5Layer23run_animation_callbacksEPv + 308
27 libdispatch.dylib 0x0000000107f8e49b _dispatch_client_callout + 8
28 libdispatch.dylib 0x0000000107f762af _dispatch_main_queue_callback_4CF + 1738
29 CoreFoundation 0x00000001044d9d09 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
30 CoreFoundation 0x000000010449b2c9 __CFRunLoopRun + 2073
31 CoreFoundation 0x000000010449a828 CFRunLoopRunSpecific + 488
32 GraphicsServices 0x0000000107a2aad2 GSEventRunModal + 161
33 UIKit 0x0000000104926610 UIApplicationMain + 171
34 AutoTutor 0x000000010379a8ef main + 111
35 libdyld.dylib 0x0000000107fc292d start + 1
36 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

ATPractice 是用于带有文本字段的 View Controller 的类的名称,answerBox 是文本字段的名称。任何帮助将不胜感激。

初始viewController的.m文件:

#import "ViewController.h"



@interface ViewController ()

@end

@implementation ViewController


- (void)viewDidLoad {

[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

里面没有任何内容,这是默认内容。

初始viewController的.h文件:

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface ViewController : UIViewController
{

}

@end

同样,默认内容。

使用退出按钮的 .m 文件查看 Controller

#import "ATPractice.h"
#import "DDMathParser.h"
#import <AVFoundation/AVFoundation.h>

@interface ATPractice ()

@end

@implementation ATPractice

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end

带有一些额外导入的默认内容。

使用退出按钮的 .h 文件查看 Controller

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>

@interface ATPractice : UIViewController <UITextFieldDelegate>
{
IBOutlet UILabel *instructionsLabel;
IBOutlet UILabel *questionLabel;
IBOutlet UILabel *percentageLabel;
IBOutlet UILabel *levelLabel;

IBOutlet UIImageView *imageView;
IBOutlet UITextField *answerBox;

IBOutlet UIScrollView *zoomView;

NSInteger questionInt;
NSInteger levelInt;
}
@end

只是一些 IBOutlets 和 NSIntegers。

最佳答案

检查您的 Nib / Storyboard,确保没有任何杂散连接。看起来您的 UITextField 上可能有一个用于其操作之一的操作。

关于更改 View 时 iOS 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35073299/

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