我的UIlabel没有更新,我想更新移动车辆或自行车等的速度?

时间:2013-07-24 21:50:31

标签: ios objective-c uilabel

我想为我的uilabel更新整数以获得速度,但它似乎无法正常工作。请继续解决基本问题,但这会让我感到困扰一段时间。我创建了一个mainviewcontroller.xib视图并尝试设置我的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;

有人建议给我一个想法吗?我想。为什么价值没有通过的任何想法?

1 个答案:

答案 0 :(得分:1)

这很可能是因为您没有更新speedCount变量。它处于待命阶段。你需要这样做:

// have number shown after being increased
speedCount++

之前需要这样做
[speedView setText: [NSString stringWithFormat:@"number is %@d",speedCount]];

线

希望这有帮助!