我想更新我的 uilabel 的整数以提高速度,但它似乎不起作用。抱歉这个基本问题,但这让我困扰了一段时间。我创建了一个 mainviewcontroller.xib View 并尝试设置我的 Uilabel,但它们没有更新。我的 uilabel 叫做 speedView
- (void)viewDidLoad {
[super viewDidLoad];
CLController = [[CoreLocationController alloc] init];
CLController.delegate = self;
[CLController.locMgr startUpdatingLocation];
}
- (void)locationUpdate:(CLLocation *)location {
NSNumber *speedCount = [NSNumber numberWithInt:1];
[speedView setText: [NSString stringWithFormat:@"number is %@d",speedCount]];
}
- (void)locationError:(NSError *)error {
speedView.text = [error description];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return YES;
}
- (void)viewDidUnload {
}
- (void)dealloc {
[CLController release];
[super dealloc];
}
@end
@interface MainViewController : UIViewController <LoginDelegate,WEPopoverParentView,PopoverControllerDelegate,MainMenuDelegate,MKMapViewDelegate,UIActionSheetDelegate, CLLocationManagerDelegate>
{
AppDelegate *appDelegate;
IBOutlet MKMapView *userMap;
IBOutlet UILabel *speedView;
}
@property (strong, nonatomic) IBOutlet UILabel *speedView;
@property(nonatomic) int speedCount;
- (void)setSpeedView:(UILabel *)speedView;
有人给我建议吗?我想。有什么想法为什么值(value)没有体现出来吗?
最佳答案
这很可能是因为您没有更新 speedCount 变量。目前只是处于待机阶段。您需要这样做:
// have number shown after being increased
speedCount++
这将在您的
之前需要[speedView setText: [NSString stringWithFormat:@"number is %@d",speedCount]];
行
希望这对您有所帮助!
关于ios - 我的 UIlabel 没有更新,我想让它更新移动车辆或自行车等的速度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17845411/