PFLogInViewController
不提供改变这种行为的钩子。您可能想要构建自己的自定义PFLogInViewController
子类并覆盖登录失败时显示警报视图的方法。
由于 PFLogInViewController 的代码已经开源,根据它显示警报视图的方法是_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];
}
例如,如果您喜欢以下内容,则可以在登录失败时不显示警报。定义MYLogInViewController
为的子类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];
NSString *title = NSLocalizedString(@"Login Error", @"Login error alert title in PFLogInViewController");
//
// Implement to display your custom alert view
//
}
@end
并改用它PFLogInViewController
MYLogInViewController *logInViewController = [[MYLogInViewController alloc] init];
logInViewController.delegate = self;
[self presentViewController:logInViewController animated:YES completion:nil];