私のUIPickerViewアニメーションに少し問題があります。 アニメーションを設定したので、ボタンをクリックするとUIPickerViewがスライドし、別のクリックの後にスライドします。しかし、私はの場合、の場合に問題に突き当たった。私は新しい設定boolを設定しようとしました。そして、各アニメーションの後に値を設定しました。なら、はブールをチェックしていました。私はそれをうまく説明したかどうかは分かりませんが、コードからそのアイデアを得るかもしれません。 残念ながら、それは動作していない...任意のアイデア?UIPickerViewが表示されているかどうかを確認していますか? * if *条件?
- (void)viewDidLoad
{
[super viewDidLoad];
settings = [NSUserDefaults standardUserDefaults];
[settings setBool:NO forKey:@"pickerShown"];
[settings synchronize];
}
- (IBAction)showPicker:(id)sender {
CGRect rect = countryPicker.frame;
CGPoint origin = CGPointMake(0, 510); // Some off-screen y-offset here.
rect.origin = origin;
countryPicker.frame = rect;
if ([settings boolForKey:@"pickerShown"] == YES) {
// Perform transform to slide it off the screen.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
countryPicker.transform = CGAffineTransformMakeTranslation(0, -0); // Offset.
[UIView commitAnimations];
[settings setBool:NO forKey:@"pickerShown"];
[settings synchronize];
} else if ([settings boolForKey:@"pickerShown"] == NO) {
// Perform transform to slide it onto the screen.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
countryPicker.transform = CGAffineTransformMakeTranslation(0, -266); // Offset.
[UIView commitAnimations];
[settings setBool:YES forKey:@"pickerShown"];
[settings synchronize];
}
}
EDIT:誰もが興味を持っていた場合
ちょうどソリューション... を見つけた - ここにある:
時間。ファイル:
.
.
.
{
BOOL pickerShown;
}
.
.
.
.mファイル:
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect rect = countryPicker.frame;
CGPoint origin = CGPointMake(0, 510); // Some off-screen y-offset here.
rect.origin = origin;
countryPicker.frame = rect;
pickerShown = NO;
}
- (IBAction)showPicker:(id)sender {
if (pickerShown == NO) {
// Perform transform to slide it onto the screen.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
//[UIView setAnimationDidStopSelector:@selector(hidePicker)];
countryPicker.transform = CGAffineTransformMakeTranslation(0, 0); // Offset.
[UIView commitAnimations];
[self performSelector:@selector(hidePicker) withObject:nil afterDelay:1];
} else if (pickerShown == YES) {
//countryPicker.hidden = NO;
// Perform transform to slide it onto the screen.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
countryPicker.transform = CGAffineTransformMakeTranslation(0, -266); // Offset.
[UIView commitAnimations];
countryPicker.hidden = NO;
}
}
申し訳ありませんが、それは私が意味するものではありません。私は解決策を見つけました:) –
@DomiNickHádl:他の人のためにソリューションを投稿してください。 – titaniumdecoy
これはすでに最初の投稿にあります。私は答えとしてそれを追加します:) –