ViewController 클래스에 NSTimer가 있습니다 .. 그리고 NStimer의 모든 메서드가 해당 클래스에 있습니다 .. 내 NSTimer가 제대로 재생 및 일시 중지 중입니다 ... 집 버튼을 누르면 iPhone도 타이머가 제대로 작동합니다 (응용 프로그램이 포 그라운드로 들어갈 때 응용 프로그램이 백그라운드로 들어갈 때부터 실행되기 시작 함) ... 내 응용 프로그램에서 응용 프로그램이 포어라운드로 들어갈 때 신속하게 경고를 발생합니다 (응용 프로그램의 UIAlertview) didEnterForeGround). NSTimer가 화면에 나타나면 (경고에 응답하지 않음) NSTimer가 실행 중입니다 .. 사용자가 내 경고에 응답 할 때까지 NSTimer를 중지하고 싶습니다 ... 그 후 NSTimer를 시작하고 싶습니다. 그걸 할 수 있을까 ...? 제발 도와주세요 ... 미리 감사드립니다 ... 나는 Appelegate.m 파일에서 NSTimer 메서드를 호출하고 싶습니다 ... 이러한 메서드를 올바르게 호출하는 중 ... 그리고 ViewController의 메서드가 호출됩니다 .. 그러나 작업이 수행되지 않습니다. .. 같은 방법에 대한시의 ViewController 클래스는 노력에서 전화 ...Objective C에서 NSTimer를 클릭하면 홈 버튼을 클릭
enter code here
ViewController.h
+(ExamViewController *)evcInstance;
ViewController.m
ExamViewController *evc = nil;
@implementation ExamViewController
+(ExamViewController *)evcInstance
{
if(!evc)
{
evc = [[ExamViewController alloc] init];
}
return evc;
}
- (void)onStartPressed
{
stopwatchtimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateTimer:) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:stopwatchtimer forMode:NSRunLoopCommonModes];
resume.hidden = YES;
resume.enabled=NO;
pause.hidden = NO;
pause.enabled=YES;
}
- (void)onStopPressed
{
[stopwatchtimer invalidate];
stopwatchtimer = nil;
pause.hidden = YES;
pause.enabled=NO;
resume.hidden = NO;
resume.enabled=YES;
}
Appdelegate.m
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[[ExamViewController evcInstance] onStopPressed];
NSLog(@"applicationWillEnterForeground");
if(viewCalled ==YES)
{
UIAlertView *alertview=[[UIAlertView alloc]initWithTitle:@"" message:@"DO! You Want To continue" delegate:self cancelButtonTitle:@"YES" otherButtonTitles:@"NO", nil];
[alertview show];
[alertview release];
}
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
}
내 질문을 편집했습니다. 한번만 보시기 바랍니다. – SriKanth
Google에서 도와 드릴 수 있도록 해당 코드를 입력하십시오! – lnafziger
코드를 포함 시켰습니다. 한 번 확인하십시오 .. – SriKanth