2015-01-03 2 views
1

난 건반이 performSegueWithIdentifier:에 의해 천천히 호출되지만 트리거하지 않습니다. 그러나, 버튼 누름으로 segue를 만들면 segue가 문제없이 작동합니다. 또한 코드에서 내 segue의 이름을 변경하려고 시도했으며 오류가 no segue with identifier입니다. 여기 건방진 수행하지 않음

내 코드 (참고 : SEGUE은 (는) 코드에서 다른 곳에서 일하는 것이 있는지 확인하는 두 개의 서로 다른 장소에서라고합니다.)입니다 해명

#import "SignUpViewController.h" 
#import "ProgressHUD.h" 

@interface SignUpViewController() 

@end 

@implementation SignUpViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 
    [self performSegueWithIdentifier:@"profilePic" sender:self]; 

} 

- (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. 
} 
*/ 

- (IBAction)createAnAccount:(id)sender { 

    [ProgressHUD show:@"Please Wait"]; 

    if ([self.passwrod.text isEqualToString:self.confirmPassword.text]){ 
     // Register User 
     PFUser *user = [PFUser user]; 
     user.username = self.username.text; 
     user.password = self.passwrod.text; 
     user.email = self.eMail.text; 

     // other fields can be set if you want to save more information 

     NSString *name = [self.firstName.text stringByAppendingString:@" "]; 
     NSString *fullName = [name stringByAppendingString:self.lastName.text]; 

     user[@"name"] = fullName; 

     user[@"posts"]  = @0; 
     user[@"score"]  = @5; 
     user[@"followers"] = @0; 
     user[@"following"] = @0; 

     [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { 
      if (!error) { 

       // Hooray! Let them use the app now. 

       [self performSegueWithIdentifier:@"profilePic" sender:self]; 

       [ProgressHUD showSuccess:nil]; 
       NSLog(@"Perform Segue"); 

      } else { 
       NSString *errorString = [error userInfo][@"error"]; 
       // Show the errorString somewhere and let the user try again. 

       [ProgressHUD showError:errorString]; 
      } 
     }]; 

    } else { 
     // Alert User 
     [ProgressHUD showError:@"Please check your passwords as they do not match."]; 
    } 

} 

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    NSLog(@"Preparing for segue"); 
    NSLog(@"Segue: %@", segue.identifier); 
} 

@end 

업데이트 : prepareForSegue 메서드가 호출되고 있으며, 벌채 반출.

도움 주셔서 감사합니다.

+0

IB에서 segue 식별자의 이름을 지정하지 않았기 때문에 오류가 발생합니다. 여기를 참조하십시오 (http://stackoverflow.com/questions/25020866/receiver-has-no-segue-with-identifier-when-identifier-exists) 그리고 만약 당신이 식별자를 가지고 있다면 VC – soulshined

답변

0

저에게 도움이되는 해결책은 문제의보기 컨트롤러에 모든 세그먼트를 삭제 한 다음 다시 추가하는 것입니다. 이것은 모든 사람들에게 잘 작동하지는 않을 것이나, 그럴만 한 가치가 있습니다.

4

전화 performSegueWithIdentifierviewDidLoad에 넣지 마십시오. 실제로 콘솔에서 경고 또는 오류가 표시됩니다. 대신 viewDidAppear으로 전화를 이동하십시오.

+0

을 인스턴스화 할 수 있습니다 또한 백그라운드 블록에서 호출하는 것은 나쁜 생각입니다. – Paulw11

+0

OP는 IBAction을 기반으로 작업을 수행하기 때문에 실행 가능한 옵션이 아닙니다. VC에 대한 화면이 나타날 때마다 제안 사항이 강제로 segue가됩니다. 좋은 일이 아닙니다. OP는 그들이 작동하는지 알아보기 위해 그곳에 놓았습니다. – soulshined

+0

사실, 그는 IBAction에서 잘 작동한다고 말했습니다. – stromdotcom

관련 문제