저는 Objective-C를 처음 접했고 귀하의 도움이 필요합니다! 아래에서 볼 수있는 코드에서 내 레이블은 선택기보기에서 데이터를 선택합니다. 사용자가 픽커보기에서 값을 변경하자마자 실시간으로 "chargeLabel.text"를 업데이트하기 위해 "calculate"IBAction을 사용하는 대신에 싶습니다.Objective-C : 자동 업데이트 레이블 텍스트
-(IBAction)calculate:(id)sender {
float floatTime;
if ([typeLabel.text isEqualToString:@"NiMH"])
{
floatTime=([mAhLabel.text floatValue]/chargerSlider.value)*1.5;
} else {
floatTime=([mAhLabel.text floatValue]/chargerSlider.value)*1.4;
}
int intHourhs=(floatTime);
float floatHours=(intHourhs);
float floatMinutes=(floatTime-floatHours)*60;
NSString *stringTotal = [NSString stringWithFormat: @"Hours: %.0i Minutes: %.0f", intHourhs, floatMinutes];
chargeLabel.text=stringTotal;
}