Ios can';t使用准备segue方法执行segue

Ios can';t使用准备segue方法执行segue,ios,objective-c,storyboard,segue,parse-platform,Ios,Objective C,Storyboard,Segue,Parse Platform,您好,我正在尝试使用prepareforsegue方法执行segue。我一直在关注这个问题,但我无法成功注册。当我单击“注册”按钮时,它所做的只是注册用户并在那里停止。我通过视图控制器(而不是按钮本身)连接了我的segue,所以这一点没有问题。我的发送视图只是一个带有文本字段和“完成”按钮的普通视图,而我的接收视图是一个静态表视图,行上有一个标签(称为nameLabel) 2个问题 1.我的prepare for segue方法缺少什么?(我也将parse用作后端,因此PFLogInSucces

您好,我正在尝试使用prepareforsegue方法执行segue。我一直在关注这个问题,但我无法成功注册。当我单击“注册”按钮时,它所做的只是注册用户并在那里停止。我通过视图控制器(而不是按钮本身)连接了我的segue,所以这一点没有问题。我的发送视图只是一个带有文本字段和“完成”按钮的普通视图,而我的接收视图是一个静态表视图,行上有一个标签(称为nameLabel)

2个问题

1.我的prepare for segue方法缺少什么?(我也将parse用作后端,因此PFLogInSuccessNotification来自于此)

  • 如何将用户的用户名传递到我的纵断面图
  • 谢谢你花时间帮忙

    **my segue method**
    
     -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        NSLog(@"can you see this");
        if ([segue.identifier isEqualToString:@"SegueTOprofile"])
        {
            if (PFLogInSuccessNotification) {
           profileTableViewController *myProfileView = (profileTableViewController *)[segue destinationViewController];
    
                PFUser *user =[PFUser user];
                user.username = myProfileView.nameLabel.text;
                       //   NSLog(@"%@",myProfileView.nameLabel.text);
        }
    
        }
        [self performSegueWithIdentifier:@"SegueTOprofile" sender:self];
    
    
    }
    
    **这是我的注册视图** h

    #导入
    extern NSString*常量PFSIGNUPSUCCESS通知;
    外部NSString*常量PFSignUpFailureNotification;
    @界面注册ViewController:UIViewController
    @属性(强,非原子)IBOutlet UITextField*emailNameField;
    @属性(强,非原子)IBUITextField*passwordField;
    @属性(强,非原子)IBUIButton*signupButton;
    -(iAction)注册:(id)发件人;
    @属性(强,非原子)IBOutlet UITextField*repeatPasswordField;
    @属性(强,非原子)IBUIBarbuttonItem*BackButton;
    @属性(强,非原子)IBOutlet UITextField*usernameField;
    
    m

    #导入“SignUpViewController.h”
    #导入“profileTableViewController.h”
    #进口
    #导入“ActivityView.h”
    #导入“TabBarCustomClassViewController.h”
    @接口SignUpViewController()
    -(作废)处理字段条目;
    -(作废)文本输入更改:(NSNotification*)注释;
    -(BOOL)应启用一个按钮;
    @结束
    @实现注册视图控制器
    @综合signupButton=_signupButton;
    -(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对象:_emailNameField];
    [[NSNotificationCenter defaultCenter]添加观察者:自选择器:@selector(textInputChanged:)名称:UITextFieldTextDidChangeNotification对象:_passwordField];
    [[NSNotificationCenter defaultCenter]添加观察者:自选择器:@selector(textInputChanged:)名称:UITextFieldTextDidChangeNotification对象:_repeatPasswordField];
    }
    -(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation{
    //对于支持的方向返回YES
    返回(interfaceOrientation==UIInterfaceOrientationGraphic);
    }
    -(BOOL)textField应返回:(UITextField*)textField
    {
    if(textField==\u usernameField){
    [\u usernameField成为第一响应者];
    }
    如果(textField==\u emailNameField){
    [\u emailNameField成为第一响应者];}
    if(textField==\u passwordField){
    [[u passwordField成为第一响应者];
    }
    if(textField==\u repeatPasswordField){
    [_repeatPasswordField成为第一响应者];
    }
    返回YES;
    }
    -(BOOL)应禁用一个按钮
    {
    BOOL enableDoneButton=否;
    如果(_emailNameField.text!=nil&&&u passwordField.text!=nil&&u repeatPasswordField!=nil&&u usernameField.text!=nil){
    enableDoneButton=YES;
    }
    返回使能按钮;
    }
    /*
    //使用segue-->将当前选定的配置文件发送到“ProfileView”
    ProfileViewController*aProfileView=(ProfileViewController*)[segue destinationViewController];
    aProfileView.currentProfile=selectedProfile*/
    -(void)prepareForSegue:(UIStoryboardSegue*)segue发送方:(id)发送方
    {
    NSLog(@“你能看到这个吗”);
    if([segue.identifier IsequalString:@“SegueTOprofile”])
    {
    if(PFLogInSuccessNotification){
    profileTableViewController*myProfileView=(profileTableViewController*)[segue destinationViewController];
    PFUser*user=[PFUser-user];
    user.username=myProfileView.namelab.text;
    //NSLog(@“%@”,myProfileView.nameLabel.text);
    }
    }
    [self-PerformsgueWithIdentifier:@“SegueTOprofile”发件人:self];
    }
    -(无效)textInputChanged:(NSNotification*)注释
    {
    _signupButton.enabled=[self shouldEnableDoneButton];
    }
    -(无效)未收到记忆警告
    {
    [超级记忆警告];
    //处置所有可以重新创建的资源。
    }
    -(iAction)注册:(id)发件人{
    [[u usernameField辞职firstresponder];
    [_emailNameField辞职FirstResponder];
    [[u passwordField辞职FirstResponder];
    [_repeatPasswordField辞职FirstResponder];
    [自我处理字段输入];
    }
    -(作废)processFieldEntries
    {
    //检查我们是否有非零用户名和密码。
    //再次比较password和password是否相等
    //抛出一个对话,告诉他们如果他们做错了,他们做错了什么。
    NSString*email=\u emailNameField.text;
    NSString*passwordd=\u passwordField.text;
    NSString*passwordAgainn=\u repeatPasswordField.text;
    NSString*username=\u usernameField.text;
    NSString*errorText=@“请”;
    NSString*UsernameBankText=@“输入用户名”;
    NSString*passwordBlankText=@“输入密码”;
    NSString*joinText=@“,和”;
    NSString*passwordmistchtext=@“输入相同的密码两次”;
    BOOL textError=否;
    if(email.length==0 | | passwordd.length==0 | | passwordAgainn.length==0){
    text错误=是;
    //为缺少输入的第一个字段设置键盘:
    if(passwordAgainn.length==0){
    [[u]重复通行证
    
    #import <UIKit/UIKit.h>
    extern NSString *const PFSignUpSuccessNotification;
    extern NSString *const PFSignUpFailureNotification;
    
    @interface SignUpViewController : UIViewController<UITextFieldDelegate>
    
    
    @property (strong, nonatomic) IBOutlet UITextField *emailNameField;
    @property (strong, nonatomic) IBOutlet UITextField *passwordField;
    @property (strong, nonatomic) IBOutlet UIButton *signupButton;
    - (IBAction)SignUp:(id)sender;
    @property (strong, nonatomic) IBOutlet UITextField *repeatPasswordField;
    @property (strong, nonatomic) IBOutlet UIBarButtonItem *BackButton;
    @property (strong, nonatomic) IBOutlet UITextField *usernameField;
    
    #import "SignUpViewController.h"
    #import "profileTableViewController.h"
    #import <Parse/Parse.h>
    #import "ActivityView.h"
    #import "TabBarCustomClassViewController.h"
    @interface SignUpViewController ()
    
    -(void)processFieldEntries;
    - (void)textInputChanged:(NSNotification *)note;
    - (BOOL)shouldEnableDoneButton;
    
    @end
    
    @implementation SignUpViewController
    @synthesize signupButton = _signupButton;
    
    - (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:_emailNameField];
    
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textInputChanged:) name:UITextFieldTextDidChangeNotification object:_passwordField];
    
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textInputChanged:) name:UITextFieldTextDidChangeNotification object:_repeatPasswordField];
    
    
    }
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    
    -(BOOL)textFieldShouldReturn:(UITextField *)textField
    {
        if (textField == _usernameField) {
            [_usernameField becomeFirstResponder];
        }
        if (textField == _emailNameField) {
      [_emailNameField becomeFirstResponder];}
        if (textField == _passwordField) {
            [_passwordField becomeFirstResponder];
        }
        if (textField == _repeatPasswordField) {
            [_repeatPasswordField becomeFirstResponder];
        }
    
        return  YES;
    }
    
    -(BOOL)shouldEnableDoneButton
    {
        BOOL enableDoneButton = NO;
        if (_emailNameField.text != nil && _passwordField.text != nil && _repeatPasswordField != nil && _usernameField.text != nil) {
            enableDoneButton = YES;
        }
        return enableDoneButton;
    }
    /*
     // Using segue --> Send the current selected profile to "ProfileView"
     ProfileViewController *aProfileView = (ProfileViewController *)[segue destinationViewController];
     aProfileView.currentProfile = selectedProfile; */
    
    
     -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        NSLog(@"can you see this");
        if ([segue.identifier isEqualToString:@"SegueTOprofile"])
        {
            if (PFLogInSuccessNotification) {
           profileTableViewController *myProfileView = (profileTableViewController *)[segue destinationViewController];
    
                PFUser *user =[PFUser user];
                user.username = myProfileView.nameLabel.text;
                       //   NSLog(@"%@",myProfileView.nameLabel.text);
        }
    
        }
        [self performSegueWithIdentifier:@"SegueTOprofile" sender:self];
    
    
    }
    
    
    
    -(void)textInputChanged:(NSNotification *)note
    {
        _signupButton.enabled = [self shouldEnableDoneButton];
    
    }
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    - (IBAction)SignUp:(id)sender {
        [_usernameField resignFirstResponder];
        [_emailNameField resignFirstResponder];
        [_passwordField resignFirstResponder];
        [_repeatPasswordField resignFirstResponder];
        [self processFieldEntries];
    }
    -(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 *email = _emailNameField.text;
        NSString *passwordd = _passwordField.text;
        NSString *passwordAgainn = _repeatPasswordField.text;
        NSString *username = _usernameField.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;
    
        if (email.length == 0 || passwordd.length == 0 || passwordAgainn.length == 0) {
            textError = YES;
    
            // Set up the keyboard for the first field missing input:
            if (passwordAgainn.length == 0) {
                [_repeatPasswordField becomeFirstResponder];
            }
            if (passwordd.length == 0) {
                [_passwordField becomeFirstResponder];
            }
            if (username.length == 0) {
                [_usernameField becomeFirstResponder];
            }
    
            if (email.length == 0) {
                errorText = [errorText stringByAppendingString:usernameBlankText];
            }
    
            if (passwordd.length == 0 || passwordAgainn.length == 0) {
                if (email.length == 0) { // We need some joining text in the error:
                    errorText = [errorText stringByAppendingString:joinText];
                }
                errorText = [errorText stringByAppendingString:passwordBlankText];
            }
        } else if ([passwordd compare:passwordAgainn] != NSOrderedSame) {
            // We have non-zero strings.
            // Check for equal password strings.
            if (_signupButton.enabled == YES) {
                textError = YES;
                errorText = [errorText stringByAppendingString:passwordMismatchText];
    
            }
        }
        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.
        _signupButton.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 You Up";
        label.font = [UIFont boldSystemFontOfSize:20.f];
        [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.
    
        PFUser *user = [PFUser user];
    
        user.email = email;
        user.password = passwordAgainn;
        user.username = username;
        [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];
                _signupButton.enabled = [self shouldEnableDoneButton];
                [activityView.activityIndicator stopAnimating];
                [activityView removeFromSuperview];
                // Bring the keyboard back up, because they'll probably need to change something.
                [_emailNameField becomeFirstResponder];
    
                return;
            }
    
            // Success!
            [activityView.activityIndicator stopAnimating];
            [activityView removeFromSuperview];
    
    
    
    
    }];
    }
    @end
    
    [self shouldPerformSegueWithIdentifier:@"SegueTOprofile" sender:self];
    
    [self performSegueWithIdentifier:@"SegueTOprofile" sender:self];