Я создаю приложение, которое имеет много видов. В какой-то момент, после нажатия кнопки, вид изменяется с одного вида на исходный контроллер просмотра. Начальный контроллер просмотра не имеет ничего, кроме кода по умолчанию, который добавляется при создании нового класса, единственное, для чего он используется, - это удерживать кнопки, которые используются для переключения на другие виды. Вид с кнопкой имеет textField, кнопку «Quit» и пару ярлыков. Если я нажимаю кнопку «Выход» без, касаясь текстового поля, все идет хорошо, и я возвращаюсь к исходному контроллеру представления, где я могу продолжить. Однако, если я решила отредактировать (или даже открыть клавиатуру) на текстовом поле, а затем нажать кнопку выхода, приложение выйдет из строя, ошибка sigabrt. Это код ошибки, который я получаю.Сбой приложения iOS при изменении просмотров
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 с TextField и answerBox это имя TextField. Любая помощь будет принята с благодарностью.
.m файл начальной ViewController в:
#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
Ничего там происходит, это содержание по умолчанию.
.h файл начальной ViewController в:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface ViewController : UIViewController
{
}
@end
Опять содержимое по умолчанию.
View Controller с файлом .m отказа от курения баттона
#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
содержимое по умолчанию с некоторым дополнительным импортом.
View Controller с .h файле Quit баттона
#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.
Это будет трудно помочь без кода, соответствующие места, которые я бы выполнил, будут действием, которое запускает кнопка «quit», и если вы задаете делегат из 'UITextField' соответствующие методы делегата –
Если' answerBox 'является свойством, я предполагаю, что вы вызываете' answerBox: ', когда вы должны называть' answerBox' без двоеточия. – chedabob
@MarkE Единственное действие, которое имеет кнопка quit, - это модальный переход к исходному контроллеру View. Файлы .m для обоих контроллеров View пусты, кроме кода по умолчанию, который поставляется вместе с ним при создании нового файла. Файл .h для исходного View Controller имеет только содержимое по умолчанию, а .h для одного с кнопкой quit имеет несколько импорта ('' '' #import '' '', ' '' '#import ' '' 'и UIKit). Остальные - это только IBOutlets и NSIntegers. Как установить делегат UITextField? –
JustMe