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

标签 ios objective-c uilabel

我想更新我的 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/

相关文章:

ios - 用于管理观察者的 Objective-C 设计模式

android - Cocos2d-x项目中异步文件下载

objective-c - NS_SWIFT_NAME 不工作 : 'swift_name' attribute has invalid identifier for parameter name

objective-c - DataSource 模式与在配置对象时设置属性

objective-c - 扩展 NSManagedObject 的 delete 方法

objective-c - 新的 NSAttributedString 多行

objective-c - 在 objective-c 中从 uilabel 获取文本

UILabel 的 IOS 8 问题?

android - 在 TListView 上设置分组

ios - 在 3.5” 和 4” 显示器上均匀排列 UIButton