Я довольно новичок в программировании Objective C в Xcode и столкнулся с проблемой приложения, которое я пытаюсь сделать. Я где-то читал, что речь идет о выпуске памяти, но поскольку я новичок, я не совсем уверен, как это исправить.Непризнанный селектор, отправленный на экземпляр контроллера
Вот мой код, который, кажется, содержит проблему.
#import "SignUpViewController.h"
@interface SignUpViewController() <UITextFieldDelegate>
@end
@implementation SignUpViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.fullName.delegate = self;
self.usernameField.delegate = self;
self.passwordField.delegate = self;
self.emailField.delegate = self;
self.navigationItem.title = @"SIGN UP";
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
}
- (void)viewWillAppear:(BOOL)animated {
}
#pragma mark - Animations
-(void)textFieldDidBeginEditing:(UITextField *)textField {
self.navigationController.navigationBar.hidden = YES;
[UIView beginAnimations:nil context:NULL];
CGRect fullName = CGRectMake(31, 51, 259, 30);
CGRect usernameField = CGRectMake(31, 79, 259, 30);
CGRect passwordField = CGRectMake(31, 107, 259, 30);
CGRect emailField = CGRectMake(31, 135, 259, 30);
CGRect signUpBox = CGRectMake(0, -360, 320, 610);
CGRect signUpButton = CGRectMake(31, 183, 259, 30);
[self.fullName setFrame:fullName];
[self.usernameField setFrame:usernameField];
[self.passwordField setFrame:passwordField];
[self.emailField setFrame:emailField];
[self.signUpBox setFrame:signUpBox];
[self.signUpButton setFrame:signUpButton];
[UIView commitAnimations];
}
-(void)textFieldDidEndEditing:(UITextField *)textField {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.7];
CGRect fullName = CGRectMake(31, 369, 259, 30);
CGRect usernameField = CGRectMake(31, 397, 259, 30);
CGRect passwordField = CGRectMake(31, 425, 259, 30);
CGRect emailField = CGRectMake(31, 453, 259, 30);
CGRect signUpBox = CGRectMake(0, -42, 320, 610);
CGRect signUpButton = CGRectMake(31, 501, 259, 30);
[self.fullName setFrame:fullName];
[self.usernameField setFrame:usernameField];
[self.passwordField setFrame:passwordField];
[self.emailField setFrame:emailField];
[self.signUpBox setFrame:signUpBox];
[self.signUpButton setFrame:signUpButton];
[UIView commitAnimations];
self.navigationController.navigationBar.hidden = NO;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
#pragma mark - Helper Methods
- (IBAction)signUp:(id)sender {
NSString *fullName = self.fullName.text;
NSString *username = self.usernameField.text;
NSString *password = self.passwordField.text;
NSString *email = self.emailField.text;
if ([username length] == 0 || [password length] == 0 || [email length] == 0 || [fullName length] == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops!" message:@"Make sure you enter a username, password and email." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}
@end
я нажимаю на кнопке с действием называется SIGNUP, и я получаю эту ошибку:
2014-02-02 15:22:42.909 PhotosApp2[1538:80b] -[SignUpViewController signIn:]: unrecognized selector sent to instance 0x10e754210
2014-02-02 15:22:42.913 PhotosApp2[1538:80b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SignUpViewController signIn:]: unrecognized selector sent to instance 0x10e754210'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102741795 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001024a4991 objc_exception_throw + 43
2 CoreFoundation 0x00000001027d2bad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010273309d ___forwarding___ + 973
4 CoreFoundation 0x0000000102732c48 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000101108096 -[UIApplication sendAction:to:from:forEvent:] + 80
6 UIKit 0x0000000101108044 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17
7 UIKit 0x00000001011dc450 -[UIControl _sendActionsForEvents:withEvent:] + 203
8 UIKit 0x00000001011db9c0 -[UIControl touchesEnded:withEvent:] + 530
9 UIKit 0x000000010113cc15 -[UIWindow _sendTouchesForEvent:] + 701
10 UIKit 0x000000010113d633 -[UIWindow sendEvent:] + 988
11 UIKit 0x0000000101116fa2 -[UIApplication sendEvent:] + 211
12 UIKit 0x0000000101104d7f _UIApplicationHandleEventQueue + 9549
13 CoreFoundation 0x00000001026d0ec1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x00000001026d0792 __CFRunLoopDoSources0 + 242
15 CoreFoundation 0x00000001026ec61f __CFRunLoopRun + 767
16 CoreFoundation 0x00000001026ebf33 CFRunLoopRunSpecific + 467
17 GraphicsServices 0x00000001038703a0 GSEventRunModal + 161
18 UIKit 0x0000000101107043 UIApplicationMain + 1010
19 PhotosApp2 0x0000000100004a53 main + 115
20 libdyld.dylib 0x000000010300f60d start + 1
21 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Был ли ваш метод действий '-signUp:' однажды называется '' -signIn: '? Если это так, ваш XIB, возможно, не был обновлен для нового имени метода. – trudyscousin
У вас есть метод singUp: 'там не' signIn: 'так, может быть, некорректная настройка целевого метода кнопки? И используйте методы '[UIView animateWith ...]', чем 'beginAnimations'. –
В какой строке вы получаете эту ошибку? –