0

我想为我的 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;

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

4

1 回答 1

1

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

// have number shown after being increased
speedCount++

这将是你之前需要的

[speedView setText: [NSString stringWithFormat:@"number is %@d",speedCount]];

线

希望这可以帮助!

于 2013-07-24T21:58:09.210 回答