我正在使用导航控制器,其结构如下图所示。当用户在SigupViewController上并且成功时,我调用
[self.navigationController popToRootViewControllerAnimated:YES];
这会导致以下错误。如果我删除此行,我不会收到错误。奇怪的是,我在LoginViewController(之前的那一行)中有相同的行,当它被调用时,它按预期执行而没有错误。关于我应该修复什么的任何建议?
错误:
2014-03-05 06:39:49.240 Walk With Me[2035:70b] worked
2014-03-05 06:39:49.245 Walk With Me[2035:70b] -[SigupViewController signup:]: unrecognized selector sent to instance 0xa5599b0
2014-03-05 06:39:49.249 Walk With Me[2035:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SigupViewController signup:]: unrecognized selector sent to instance 0xa5599b0'
*** First throw call stack:
(
0 CoreFoundation 0x038635e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x035e68b6 objc_exception_throw + 44
2 CoreFoundation 0x03900903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0385390b ___forwarding___ + 1019
4 CoreFoundation 0x038534ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x035f881f -[NSObject performSelector:withObject:] + 70
6 UIKit 0x023560c2 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x0235604e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x0244e0c1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x0244e484 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x02a32853 -[UITextField _resignFirstResponder] + 300
11 UIKit 0x024ae08e -[UIResponder _finishResignFirstResponder] + 181
12 UIKit 0x024ae1b6 -[UIResponder resignFirstResponder] + 288
13 UIKit 0x02a325f4 -[UITextField resignFirstResponder] + 118
14 UIKit 0x023af044 -[UIView(Hierarchy) _removeFirstResponderFromSubtree] + 205
15 UIKit 0x023af366 __UIViewWillBeRemovedFromSuperview + 71
16 UIKit 0x023af238 -[UIView(Hierarchy) removeFromSuperview] + 70
17 UIKit 0x0267a6a3 -[UINavigationTransitionView _cleanupTransition] + 103
18 UIKit 0x0267a93a -[UINavigationTransitionView _navigationTransitionDidStop] + 55
19 UIKit 0x023a0c6c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 267
20 UIKit 0x0239f455 +[UIViewAnimationState popAnimationState] + 334
21 UIKit 0x023b3cf6 +[UIView(Animation) commitAnimations] + 36
22 UIKit 0x0267a3f9 -[UINavigationTransitionView transition:fromView:toView:] + 2795
23 UIKit 0x02679906 -[UINavigationTransitionView transition:toView:] + 55
24 UIKit 0x0248ed47 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3186
25 UIKit 0x0248f09c -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
26 UIKit 0x0248fcb9 -[UINavigationController __viewWillLayoutSubviews] + 57
27 UIKit 0x025c9181 -[UILayoutContainerView layoutSubviews] + 213
28 UIKit 0x023bf267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
29 libobjc.A.dylib 0x035f881f -[NSObject performSelector:withObject:] + 70
30 QuartzCore 0x0222e2ea -[CALayer layoutSublayers] + 148
31 QuartzCore 0x022220d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
32 QuartzCore 0x02221f40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
33 QuartzCore 0x02189ae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
34 QuartzCore 0x0218ae71 _ZN2CA11Transaction6commitEv + 393
35 QuartzCore 0x0218b544 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
36 CoreFoundation 0x0382b4ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
37 CoreFoundation 0x0382b41f __CFRunLoopDoObservers + 399
38 CoreFoundation 0x03809344 __CFRunLoopRun + 1076
39 CoreFoundation 0x03808ac3 CFRunLoopRunSpecific + 467
40 CoreFoundation 0x038088db CFRunLoopRunInMode + 123
41 GraphicsServices 0x045be9e2 GSEventRunModal + 192
42 GraphicsServices 0x045be809 GSEventRun + 104
43 UIKit 0x02354d3b UIApplicationMain + 1225
44 Walk With Me 0x00005bbd main + 141
45 libdyld.dylib 0x03da470d start + 1
46 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
代码:
PFUser *user = [PFUser user];
user.username = username;
user.password = password;
user.email = email;
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
NSLog(@"worked");
[self.navigationController popToRootViewControllerAnimated:YES];
}
else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:[error.userInfo objectForKey:@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}];
SigUpViewController.h:
#import <UIKit/UIKit.h>
@interface SigupViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *usernameField;
@property (weak, nonatomic) IBOutlet UITextField *passwordField;
@property (weak, nonatomic) IBOutlet UITextField *emailField;
- (IBAction)signingU:(id)sender;
@end
答案 0 :(得分:0)
您正在致电
[SigupViewController signup:]:
但是SigupViewController
类中没有使用该签名的方法。我假设你已经把它与IB联系起来所以添加:
- (IBAction) signup:(id) sender;
在SigupViewController.h
如果是错误,也可以删除对此方法的调用。