我有一个小问题。我是 iPhone 编程的初学者,所以如果答案很明显,请原谅我。
我找到了当前的费用,并希望它在我的应用程序运行时不断更新。我试过这个:
- (void) viewWillAppear:(BOOL)animated
{
NSLog(@"viewWillAppear");
double level = [self batteryLevel];
currentCharge.text = [NSString stringWithFormat:@"%.2f %%", level];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:selfselector:@selector(updateBatteryLevel:) userInfo:nil repeats:NO];
[super viewWillAppear:animated];
}
我最初得到的读数是正确的,但它没有更新。任何帮助将非常感激!
非常感谢,
斯图尔特