華氏はNSObject
とWakingTemperature
はUIViewController
です。私は、華氏からピッカー値をWakingTemperature
に更新しています(基本的には、華氏と摂氏の2つの値がトグルするために、華氏のコードを入れます)。ピッカー値を復元する方法
今私はピッカーの値を復元するのに問題はありますが、起こっていません。ここでは私が試みたのは で、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