不能在iPhone上停止NStimer

时间:2010-12-29 07:05:54

标签: iphone

  

可能重复:
  NSTimer doesn't stop

这是奇怪的, 我在appDidfinsh方法中调用警报按钮,并根据该点击我调用viewController中定义的方法来停止计时器,但我不能停止但我可以访问我的方法

-

 (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    


                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"check" message:@" this is 2nd time!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: @"Update",nil];

                [alert show]; 


    }


    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {


            if(buttonIndex == 1) {  
    DatabaseTestViewController *vv=[ [DatabaseTestViewController alloc]init];

                [viewController handleTime];
                [vv handleTime];
    }
    }

//////////////现在在控制器类

- (void)viewDidLoad {
    [super viewDidLoad];

    NSUserDefaults *getid = [NSUserDefaults standardUserDefaults];

    getMode  = [getid stringForKey:@"AppMode"];




    timer = [NSTimer scheduledTimerWithTimeInterval: .8
                                             target: self
                                           selector: @selector(handleTimer)
                                           userInfo: nil
                                            repeats: YES];


}


- (void) handleTimer: (NSTimer *) timer

{

    NSLog(@"getModis is %@",getMode);
 //   [self.tabelView reloadData];


    //[super viewDidLoad];


            } // 





    -(void) handleTime
    {

[self.tabelView reloadData];// this is also not updating my data i actually need this 
[timer invalidate];// not working , timer still running but i can access this method


        [timer release];
        timer =nil;
    }

0 个答案:

没有答案