Objective c 使用PFLogInViewController时避免显示UIAlertView
我使用的是Objective c 使用PFLogInViewController时避免显示UIAlertView,objective-c,uialertview,pfloginviewcontroller,Objective C,Uialertview,Pfloginviewcontroller,我使用的是PFLogInViewController的一个子类,其中我希望以不同于默认行为的方式显示错误,即弹出UIAlertView 有人知道是否有办法避免显示UIAlertView?我已经在使用下面的方法,但是这实际上不允许我避免在登录失败时显示UIAlertView - (BOOL)logInViewController:(PFLogInViewController *)logInController shouldBeginLogInWithUsername:(NSString *)use
PFLogInViewController
的一个子类,其中我希望以不同于默认行为的方式显示错误,即弹出UIAlertView
有人知道是否有办法避免显示UIAlertView
?我已经在使用下面的方法,但是这实际上不允许我避免在登录失败时显示UIAlertView
- (BOOL)logInViewController:(PFLogInViewController *)logInController shouldBeginLogInWithUsername:(NSString *)username password:(NSString *)password
PFLogInViewController
不提供用于更改此行为的挂钩。您可能希望构建自己的自定义PFLogInViewController
子类,并覆盖登录失败时显示警报视图的方法
由于PFLogInViewController的代码,根据它,显示警报视图的方法是\u logindifailwitherror
例如,如果您喜欢以下内容,则无法在登录失败时显示警报。
将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];
}
@end
MYLogInViewController *logInViewController = [[MYLogInViewController alloc] init];
logInViewController.delegate = self;
[self presentViewController:logInViewController animated:YES completion:nil];
并改用它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 *logInViewController = [[MYLogInViewController alloc] init];
logInViewController.delegate = self;
[self presentViewController:logInViewController animated:YES completion:nil];