我已经在网站和网络上进行过研究,但我似乎无法正确地进行研究.
这是我的代码:
#pragma mark - Picker VIEw - (NSInteger)numberOfComponentsInPickerVIEw:(UIPickerVIEw *)pickerVIEw{ return 1;}- (NSInteger)pickerVIEw:(UIPickerVIEw *)pickerVIEw numberOfRowsInComponent:(NSInteger)component{ return 4;}- (Nsstring *)pickerVIEw:(UIPickerVIEw *)pickerVIEw TitleForRow:(NSInteger)row forComponent:(NSInteger)component{ timersArray = [[NSMutableArray alloc] init]; [timersArray addobject:@"No timer"]; [timersArray addobject:@"15 seconds"]; [timersArray addobject:@"30 seconds"]; [timersArray addobject:@"60 seconds"]; return [timersArray objectAtIndex:row];}- (voID)pickerVIEw:(UIPickerVIEw *)pickerVIEw dIDSelectRow:(NSInteger)row inComponent:(NSInteger)component{ if ([[timersArray objectAtIndex:row] isEqual:@"No timer"]) { timerIndication.text = @"No timer selected"; timersPickerVIEw.hIDden = YES; // Animation code to dismiss picker should go here } else if ([[timersArray objectAtIndex:row] isEqual:@"15 seconds"]) { timerIndication.text = @"15 seconds selected"; timersPickerVIEw.hIDden = YES; // Animation code to dismiss picker should go here } else if ([[timersArray objectAtIndex:row] isEqual:@"30 seconds"]) { timerIndication.text = @"30 seconds selected"; timersPickerVIEw.hIDden = YES; // Animation code to dismiss picker should go here } else if ([[timersArray objectAtIndex:row] isEqual:@"60 seconds"]) { timerIndication.text = @"60 seconds selected"; timersPickerVIEw.hIDden = YES; // Animation code to dismiss picker should go here }}#pragma mark - Delay method// This is where Send button should be enabled- (IBAction)selectTimer{ timersPickerVIEw.hIDden = NO; // Animation code to present picker vIEw should go here}解决方法 按下按钮后,您可以使用以下代码为选取器视图设置动画:
-(IBAction)button:(ID)sender{ [UIVIEw beginAnimations:nil context:nil]; [UIVIEw setAnimationDuration:0.6]; CGAffinetransform transfrom = CGAffinetransformMakeTranslation(0,200); PickerVIEw.transform = transfrom; PickerVIEw.Alpha = PickerVIEw.Alpha * (-1) + 1; [UIVIEw commitAnimations];}
不要忘记将以下代码添加到vIEwDIDLoad方法中
PickerVIEw.Alpha = 0; [self.vIEw addSubvIEw:PickerVIEw];
它的作用是让选择器视图在第一次点击时从屏幕顶部掉落并使选择器视图消失,您只需再次单击该按钮.从下一次单击时,选择器视图就会出现并消失.希望它帮助和工作:)
总结以上是内存溢出为你收集整理的iphone – 如何在按下按钮后显示UIPickerView动画?全部内容,希望文章能够帮你解决iphone – 如何在按下按钮后显示UIPickerView动画?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)