2015-01-16 1 views
1

UIAlertView을 팝업하는 기본 동작과 다른 방식으로 오류를 표시하려는 PFLogInViewController의 하위 클래스를 사용하고 있습니다.PFLogInViewController를 사용할 때 UIAlertView를 표시하지 마십시오

UIAlertView이 표시되지 않도록하는 방법이 있는지 아는 사람이 있습니까? 나는 이미 다음 방법을 사용하고 있습니다. 그러나 실제로는 로그인 실패시에 UIAlertView이 표시되는 것을 피할 수 없습니다.

- (BOOL)logInViewController:(PFLogInViewController *)logInController shouldBeginLogInWithUsername:(NSString *)username password:(NSString *)password 

답변

0

PFLogInViewController에는이 동작을 변경하기위한 후크가 없습니다. 사용자 정의 PFLogInViewController 서브 클래스를 빌드하고 로그인 실패시 경고보기를 표시하는 메소드를 대체 할 수 있습니다.

PFLogInViewController 코드 has been open sourced이므로 경고보기를 표시하는 방법은 _loginDidFailWithError입니다. 예를 들어

https://github.com/ParsePlatform/ParseUI-iOS/blob/master/ParseUI/Classes/LogInViewController/PFLogInViewController.m#L382-L390

- (void)_loginDidFailWithError:(NSError *)error { 
    if (_delegateExistingMethods.didFailToLogIn) { 
     [_delegate logInViewController:self didFailToLogInWithError:error]; 
    } 
    [[NSNotificationCenter defaultCenter] postNotificationName:PFLogInFailureNotification object:self]; 

    NSString *title = NSLocalizedString(@"Login Error", @"Login error alert title in PFLogInViewController"); 
    [PFUIAlertView showAlertViewWithTitle:title error:error]; 
} 

하면 다음과 같은 경우 로그인이 실패 할 때, 당신은 경고를 표시 할 수 없습니다. PFLogInViewController

@interface MYLogInViewController : PFLogInViewController 

@end 

@implementation MYLogInViewController 

- (void)_loginDidFailWithError:(NSError *)error { 
    if ([self.delegate respondsToSelector:@selector(logInViewController:didFailToLogInWithError:)]) { 
     [self.delegate logInViewController:self didFailToLogInWithError:error]; 
    } 
    [[NSNotificationCenter defaultCenter] postNotificationName:PFLogInFailureNotification object:self]; 
} 

@end 

의 서브 클래스로 MYLogInViewController을 정의하고 PFLogInViewController

MYLogInViewController *logInViewController = [[MYLogInViewController alloc] init]; 
logInViewController.delegate = self; 
[self presentViewController:logInViewController animated:YES completion:nil]; 
대신 사용
관련 문제