화씨는 NSObject
이고 WakingTemperature
은 UIViewController
입니다. 나는 화씨에서 피커 값을 WakingTemperature
(기본적으로 화씨와 섭씨는 두 개를 토글하여 토글합니다. 화씨는 코드를 넣습니다)로 업데이트합니다.피커 값을 복원하는 방법
이제 피커 값을 복원하는 데 문제가 있습니다.하지만 그런 일은 일어나지 않습니다. 여기에 내가 시도한 것입니다 updatelable, 도와주세요.
모든@interface FertilityAppAppDelegate
----------------------------------
NSInteger pickerRowCompzero;
NSInteger pickerRowCompone;
float valueConv;
@property (nonatomic) NSInteger pickerRowCompzero;
@property (nonatomic) NSInteger pickerRowCompone;
@property (nonatomic) float valueConv;
@implementation FertilityAppAppDelegate
---------------------------------------
@synthesize pickerRowCompzero,pickerRowCompone;
@synthesize valueConv;
@implementation Fahrenheit
--------------------------
- (id)init
{
/* initialize data-arrays here */
ArrayofTempIntegerofCelsius = [[NSMutableArray alloc] init];
[ArrayofTempIntegerofCelsius addObject:@"36"];
[ArrayofTempIntegerofCelsius addObject:@"37"];
[ArrayofTempIntegerofCelsius addObject:@"38"];
[ArrayofTempIntegerofCelsius addObject:@"39"];
[ArrayofTempIntegerofCelsius addObject:@"40"];
[ArrayofTempIntegerofCelsius addObject:@"41"];
ArrayofbothTempfractional = [[NSMutableArray alloc] init];
[ArrayofbothTempfractional addObject:@".0"];
[ArrayofbothTempfractional addObject:@".1"];
[ArrayofbothTempfractional addObject:@".2"];
[ArrayofbothTempfractional addObject:@".3"];
[ArrayofbothTempfractional addObject:@".4"];
[ArrayofbothTempfractional addObject:@".5"];
[ArrayofbothTempfractional addObject:@".6"];
[ArrayofbothTempfractional addObject:@".7"];
[ArrayofbothTempfractional addObject:@".8"];
[ArrayofbothTempfractional addObject:@".9"];
Appdelegate = (FertilityAppAppDelegate*)[[UIApplication sharedApplication] delegate];
return self;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
[self updateLabel];
}
-(void) updateLabel
{
Appdelegate.pickerRowCompzero=[pickerView selectedRowInComponent:0];
Appdelegate.pickerRowCompone=[pickerView selectedRowInComponent:1];
NSString *integer = [ArrayofTempIntegerofFahrenheit objectAtIndex:Appdelegate.pickerRowCompzero];
NSString *fraction = [ArrayofbothTempfractional objectAtIndex: Appdelegate.pickerRowCompone];
NSString *fahrenheit = [NSString stringWithFormat:@"%@%@",integer,fraction];
Appdelegate.valueConv = [fahrenheit floatValue];
label.text=[NSString stringWithFormat:@"%.1f",Appdelegate.valueConv];
NSLog(@"float:%f ",Appdelegate.valueConv);
edit // [pickerView reloadAllComponents];
}
"지금 피커 값을 복원하는 데 문제가 있습니까?" 그리고 whoch 메소드의 코드는 게시 했습니까 (목록의 아래 부분)? – Axel
편집, 마지막으로 선택한 선택기 값을 저장해야하지만 항상 기본값이됩니다. – SOF