2013-07-24 3 views
0

속도에 대한 내 uilabel에 대한 정수를 업데이트하고 싶지만 작동하지 않는 것 같습니다. 기본적인 질문은 있지만 지금은이 버그가 있습니다. mainviewcontroller.xib 뷰를 만들고 Uilabel을 설정하려고했지만 업데이트하지 않습니다. 내 uilabel은 speedView라고합니다UIlabel이 업데이트되지 않고 이동하는 차량이나 자전거 등의 속도를 업데이트하고 싶습니다.

- (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

'locationUpdate :'가 실제로 호출되고 있는지 확인 했습니까? 그렇다면'speedView'가'nil'이 아니라는 것을 확인 했습니까? – rmaddy

+0

방금 ​​nil로 설정했는지 확인했는데 변경하려면 어떻게해야합니까? – mrorgon

+1

'speedView'가'IBOutlet'이라면, IB에서 제대로 연결되었는지 확인하십시오. – rmaddy

답변

1

아마도 speedCount 변수를 업데이트하지 않았기 때문일 수 있습니다. 그것은 단지 대기 단계에 있습니다. 이 작업을 수행해야합니다

// have number shown after being increased 
speedCount++ 

이 당신의

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

라인 전에 필요한 꿀벌이 도움이

희망을 것입니다!

+0

내가이 오류가 나타납니다 추가 할 때이 아키텍처 및 플랫폼 – mrorgon

+0

괜찮아요, 상수 크기가 아닌 'NSNumber'인터페이스에 포인터에 산술, 글쎄, 당신은 바닥에 @property int가 있는지, 그래서 당신은 왜 같은 이름의 NSNumber도 있습니까? 당신은 int 변수를 사용할 수 있습니다. 위에서 보았 듯이 speedCount ++를 수행하면됩니다. 그러면 [speedView setText : ..]; 줄,하지만 귀하의 형식으로 @를 꺼내, 그것은 stringWithFormat되어야합니다 : @ "% d", speedCount]; – user2277872

+0

int * speedCount = [int numberWithInt : 1]; speedCount ++; [speedView setText : [NSString stringWithFormat : @ "% @ d", speedCount]; 그것은 이것처럼 보일까? – mrorgon

관련 문제