Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 验证方法不适用于';t被呼叫,而segue没有';t被触发_Ios_Objective C_Segue - Fatal编程技术网

Ios 验证方法不适用于';t被呼叫,而segue没有';t被触发

Ios 验证方法不适用于';t被呼叫,而segue没有';t被触发,ios,objective-c,segue,Ios,Objective C,Segue,我正在尝试用解析后端实现一个注册过程。我有一个名为processFieldEntries的验证方法,一旦启用了“完成”按钮,我会尝试触发我从视图控制器(而不是“完成”按钮)中通过“从视图中显示”方法模式设置的序列,但既不会调用验证方法,也不会触发序列。我设置了一些调试断点和日志断点进行调试,但是,除了它没有看到加载的视图这一事实之外,我不能再进一步了。我还尝试通过“完成”按钮设置segue。当我这样做的时候,segue被触发,不是从代码而是从故事板。如果有人能帮我弄清楚如何和segue一起调用P

我正在尝试用解析后端实现一个注册过程。我有一个名为processFieldEntries的验证方法,一旦启用了“完成”按钮,我会尝试触发我从视图控制器(而不是“完成”按钮)中通过“从视图中显示”方法模式设置的序列,但既不会调用验证方法,也不会触发序列。我设置了一些调试断点和日志断点进行调试,但是,除了它没有看到加载的视图这一事实之外,我不能再进一步了。我还尝试通过“完成”按钮设置segue。当我这样做的时候,segue被触发,不是从代码而是从故事板。如果有人能帮我弄清楚如何和segue一起调用ProcessFieldEntries,我将不胜感激。多谢各位

NewUserSignUpViewController.h

#import <UIKit/UIKit.h>
#import "ProfileViewController.h"

@interface NewUserSignUpViewController : UIViewController<UITextFieldDelegate>
@property (strong, nonatomic) IBOutlet UIBarButtonItem *barButtonItem;
@property (strong, nonatomic) IBOutlet UITextField *usernameField;
@property (strong, nonatomic) IBOutlet UITextField *passwordField;
@property (strong, nonatomic) IBOutlet UITextField *repeatPasswordField;
- (IBAction)doneEvent:(id)sender;
- (IBAction)cancelEvent:(id)sender;

@end
#导入
#导入“ProfileViewController.h”
@接口NewUserSignUpViewController:UIViewController
@性质(强的,非原子的)巴布托石*巴布托石;
@属性(强,非原子)IBOutlet UITextField*usernameField;
@属性(强,非原子)IBUITextField*passwordField;
@属性(强,非原子)IBOutlet UITextField*repeatPasswordField;
-(iAction)DoneeEvent:(id)发送方;
-(iAction)cancelEvent:(id)发送方;
@结束
NewUserSignUpViewController.m

#import "NewUserSignUpViewController.h"
#import "ProfileViewController.h"
#import <Parse/Parse.h>
#import "ActivityView.h"
@interface NewUserSignUpViewController ()
-(void)processFieldEntries;
- (void)textInputChanged:(NSNotification *)note;
- (BOOL)shouldEnableDoneButton;
@end

@implementation NewUserSignUpViewController
@synthesize barButtonItem = _doneButtonInTheBar;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textInputChanged:) name:UITextFieldTextDidChangeNotification object:_usernameField];

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textInputChanged:) name:UITextFieldTextDidChangeNotification object:_passwordField];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textInputChanged:) name:UITextFieldTextDidChangeNotification object:_repeatPasswordField];



}
-(void)viewDidAppear:(BOOL)animated
{
    [_usernameField becomeFirstResponder];
    [super viewDidAppear:animated];
    //perform the segue
    if (_doneButtonInTheBar.enabled == YES) {
        [self performSegueWithIdentifier:@"segueToProfileView" sender:self];
    }



}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)dealloc {

}

#pragma mark - UITextFieldDelegate
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{   textField.delegate = self;
    if (textField == _usernameField) {[_usernameField becomeFirstResponder];}
    if (textField == _passwordField){[_passwordField becomeFirstResponder];}
    if (textField == _repeatPasswordField)
    {

        [_repeatPasswordField becomeFirstResponder];
        [self processFieldEntries];
    }
    return YES;
}
-(BOOL)shouldEnableDoneButton
{
    BOOL enableDoneButton = NO;

    if (_usernameField.text != nil && _usernameField.text.length != 0 &&_passwordField.text != nil &&
        _passwordField.text.length !=0 && _repeatPasswordField.text != nil &&
        _repeatPasswordField.text.length != 0) {
        enableDoneButton = YES;
        [self processFieldEntries];


    }
    return enableDoneButton;
}

-(void)textInputChanged:(NSNotification *)note
{
    _doneButtonInTheBar.enabled = [ self shouldEnableDoneButton];
}
- (IBAction)doneEvent:(id)sender {
    [_usernameField resignFirstResponder];
    [_passwordField resignFirstResponder];
    [_repeatPasswordField resignFirstResponder];
    NSLog(@"processfieldentries");
    [self processFieldEntries];
}

- (IBAction)cancelEvent:(id)sender {
    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)processFieldEntries
{
    // Check that we have a non-zero username and passwords.
    // Compare password and passwordAgain for equality
    // Throw up a dialog that tells them what they did wrong if they did it wrong.
    NSString *username = _usernameField.text;
    NSString *password = _passwordField.text;
    NSString *passwordAgain = _repeatPasswordField.text;
    NSString *errorText = @"Please ";
    NSString *usernameBlankText = @"enter a username";
    NSString *passwordBlankText = @"enter a password";
    NSString *joinText = @", and ";
    NSString *passwordMismatchText = @"enter the same password twice";

    BOOL textError = NO;
// Messaging nil will return 0, so these checks implicitly check for nil text.

if (username.length == 0 ||  password.length == 0 || passwordAgain.length == 0) {
    textError = YES;
    //setting the keyboard for th first missing output
    if (passwordAgain.length == 0) {
        [_repeatPasswordField becomeFirstResponder];
    }
    if (password.length == 0) {
        [_passwordField becomeFirstResponder];
    }
    if (username.length == 0) {
        [_usernameField becomeFirstResponder];
    }

    if (username.length == 0) {
        errorText = [errorText stringByAppendingString:usernameBlankText];
    }

    if (password.length == 0 || passwordAgain.length == 0) {
        if (username.length == 0) { // We need some joining text in the error:
            errorText = [errorText stringByAppendingString:joinText];
        }
        errorText = [errorText stringByAppendingString:passwordBlankText];
    }
}else if ([password compare:passwordAgain] != NSOrderedSame)
{errorText = [errorText stringByAppendingString:passwordMismatchText];
    [_passwordField becomeFirstResponder];}
    if (textError) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:errorText message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
        [alertView show];
        return;
        // Everything looks good; try to log in.
        // Disable the done button for now.
        _doneButtonInTheBar.enabled = NO;

        ActivityView *activityView = [[ActivityView alloc]initWithFrame:CGRectMake(0.f, 0.f, self.view.frame.size.width, self.view.frame.size.height)];
        UILabel *label = activityView.label;
        label.text = @"signing up";
        label.font = [UIFont boldSystemFontOfSize:20.0f];
        [activityView.activityIndicator startAnimating];
        [activityView layoutSubviews];
        [self.view addSubview:activityView];

        // Call into an object somewhere that has code for setting up a user.
        // The app delegate cares about this, but so do a lot of other objects.
        // For now, do this inline.
        NSLog(@"does it reach here");
        PFUser *user = [PFUser user];
        user.username = username;
        user.password = password;
        [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
            if (error) {
                UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[[error userInfo] objectForKey:@"error"] message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
                [alertView show];
                _doneButtonInTheBar.enabled = [self shouldEnableDoneButton];
                [activityView.activityIndicator stopAnimating];
                [activityView removeFromSuperview];
                // Bring the keyboard back up, because they'll probably need to change something.
                [_usernameField becomeFirstResponder];
                return;
            }
            // Success!
            [activityView.activityIndicator stopAnimating];
            [activityView removeFromSuperview];
            }];

    }

}
@end
#导入“NewUserSignUpViewController.h”
#导入“ProfileViewController.h”
#进口
#导入“ActivityView.h”
@接口NewUserSignUpViewController()
-(作废)处理字段条目;
-(作废)文本输入更改:(NSNotification*)注释;
-(BOOL)应启用一个按钮;
@结束
@实现NewUserSignUpViewController
@合成巴布托宁=_doneButtonInTheBar;
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化
}
回归自我;
}
-(无效)viewDidLoad
{
[超级视图下载];
[[NSNotificationCenter defaultCenter]添加观察者:自选择器:@selector(textInputChanged:)名称:UITextFieldTextDidChangeNotification对象:_usernameField];
[[NSNotificationCenter defaultCenter]添加观察者:自选择器:@selector(textInputChanged:)名称:UITextFieldTextDidChangeNotification对象:_passwordField];
[[NSNotificationCenter defaultCenter]添加观察者:自选择器:@selector(textInputChanged:)名称:UITextFieldTextDidChangeNotification对象:_repeatPasswordField];
}
-(无效)视图显示:(BOOL)动画
{
[\u usernameField成为第一响应者];
[超级视图显示:动画];
//表演这一段
如果(_doneButtonInTheBar.enabled==是){
[self-PerformsgueWithIdentifier:@“segueToProfileView”发件人:self];
}
}
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation{
//对于支持的方向返回YES
返回(interfaceOrientation==UIInterfaceOrientationGraphic);
}
-(无效)解除锁定{
}
#pragma标记-UITextFieldDelegate
-(BOOL)textField应返回:(UITextField*)textField
{textField.delegate=self;
如果(textField==\u usernameField){[\u usernameField becomeFirstResponder];}
如果(textField==_passwordField){[_passwordfieldbecomefirstresponder];}
if(textField==\u repeatPasswordField)
{
[_repeatPasswordField成为第一响应者];
[自我处理字段输入];
}
返回YES;
}
-(BOOL)应禁用一个按钮
{
BOOL enableDoneButton=否;
如果(_usernameField.text!=nil&&u usernameField.text.length!=0&&u passwordField.text!=nil&&
_passwordField.text.length!=0&&u repeatPasswordField.text!=nil&&
_repeatPasswordField.text.length!=0){
enableDoneButton=YES;
[自我处理字段输入];
}
返回使能按钮;
}
-(无效)textInputChanged:(NSNotification*)注释
{
_doneButtonInTheBar.enabled=[self shouldEnableDoneButton];
}
-(iAction)DoneeEvent:(id)发件人{
[[u usernameField辞职firstresponder];
[[u passwordField辞职FirstResponder];
[_repeatPasswordField辞职FirstResponder];
NSLog(@“processfieldentries”);
[自我处理字段输入];
}
-(iAction)取消事件:(id)发送方{
[self.presentedViewController dismissViewControllerAnimated:YES完成:nil];
}
-(无效)未收到记忆警告
{
[超级记忆警告];
//处置所有可以重新创建的资源。
}
-(作废)processFieldEntries
{
//检查我们是否有非零用户名和密码。
//再次比较password和password是否相等
//抛出一个对话,告诉他们如果他们做错了,他们做错了什么。
NSString*username=\u usernameField.text;
NSString*password=\u passwordField.text;
NSString*password再次=\u repeatPasswordField.text;
NSString*errorText=@“请”;
NSString*UsernameBankText=@“输入用户名”;
NSString*passwordBlankText=@“输入密码”;
NSString*joinText=@“,和”;
NSString*passwordmistchtext=@“输入相同的密码两次”;
BOOL textError=否;
//消息nil将返回0,因此这些检查隐式地检查nil文本。
如果(username.length==0 | | | password.length==0 | | | password再次出现。length==0){
text错误=是;
//为第一个丢失的输出设置键盘
if(passwordreathere.length==0){
[_repeatPasswordField成为第一响应者];
}
if(password.length==0){
[[u passwordField成为第一响应者];
}
如果(username.length==0){
[\u usernameField成为第一响应者];
}
如果(username.length==0){
errorText=[errorText stringByAppendingString:UserName BlankText];
}
if(password.length==0 | | passwordreach.length==0){
如果(username.length==0){//我们需要在错误中加入一些连接文本:
errorText=[errorText stringByAppendingString:joinText];
}
errorText=[er