我需要在一段时间后自动注销用户,我能够这样做并注销应用程序导航到loginview但问题是当我在一个视图上并执行一些操作,例如从日期选择器中选择日期或者我可以在应用程序注销时打开其他弹出窗口,然后在登录视图上显示弹出窗口或日期选择器或警报视图。
所以我的问题是如何从loginview中删除它。这是我用来注销我的应用程序的代码。
@implementation MyApplication
- (void)sendEvent:(UIEvent *)event {
[super sendEvent:event];
// Only want to reset the timer on a Began touch or an Ended touch, to reduce the number of timer resets.
NSSet *allTouches = [event allTouches];
if ([allTouches count] > 0) {
UITouchPhase phase = ((UITouch *)[allTouches anyObject]).phase;
if (phase == UITouchPhaseBegan || phase == UITouchPhaseEnded)
[self resetIdleTimer];
NSLog(@"resetIdleTimer");
[[NSUserDefaults standardUserDefaults]setValue:@"no" forKey:@"istouch"];
}
}
-(void)resetIdleTimer {
if (self.idleTimer) {
[self.idleTimer invalidate];
}
NSTimeInterval timeInterval = [[[User currentUser]AutomaticLogoutTime] doubleValue]*60;
if (timeInterval > 0) {
[[NSUserDefaults standardUserDefaults]setValue:@"yes" forKey:@"istouch"];
self.idleTimer = [NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(idleTimerExceeded) userInfo:nil repeats:NO] ;
}
}
-(void)idleTimerExceeded {
[[NSNotificationCenter defaultCenter] postNotificationName:@"DataUpdated"
object:self];
}