zoukankan      html  css  js  c++  java
  • UIPickView的显示与消失方法

    //PickerView appear
    -(void)ShowPickerView:(UIPickerView*)PickerViewTag
    {
        if(PickerViewTag.superview==nil)
        {
            [self.view.window addSubview:PickerViewTag];
            CGRect screenRect=[[UIScreen mainScreen]applicationFrame];
            CGSize pickSize=[PickerViewTag sizeThatFits:CGSizeZero];
            CGRect startRect=CGRectMake(0.0, screenRect.origin.y+screenRect.size.height, pickSize.width, pickSize.height);
            PickerViewTag.frame=startRect;
            CGRect pickRect=CGRectMake(0.0, screenRect.origin.y+screenRect.origin.y+screenRect.size.height-pickSize.height, pickSize.width,pickSize.height);
           
            [UIView beginAnimations:nil context:NULL];
            [UIView setAnimationDuration:0.3];
            [UIView setAnimationDelegate:self];
            PickerViewTag.frame=pickRect;
            CGRect newFrame=self.view.frame;
            newFrame.size.height-=PickerViewTag.frame.size.height;
            self.tableView.frame=newFrame;
            [UIView commitAnimations];
        }
       
    }
    //PickerView Disappear
    -(void)PickerViewDisappear:(UIPickerView *)PickerViewTag
    {
        CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
        CGRect endFrame=PickerViewTag.frame;
        endFrame.origin.y=screenRect.origin.y+screenRect.size.height;
       
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.3];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(slideDown:)];
        PickerViewTag.frame=endFrame;
        CGRect newFrame = self.tableView.frame;
        newFrame.size.height+=PickerViewTag.frame.size.height;
       
        self.tableView.frame=newFrame;
           
        // deselect the current table row
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
        [PickerViewTag removeFromSuperview];
    }
  • 相关阅读:
    通过set和waitOne来控制子线程的运行和停止
    一种控制线程运行和停止的方法
    C# 运用params修饰符来实现变长参数传递
    ref和out的区别
    C# 抽象类和接口的区别
    更有效率的使用Visual Studio(一)
    更有效率的使用Visual Studio(二)
    RS232串口用事件接受数据(一问一答)
    socket的异步回调函数,采用一问一答
    js去重方法
  • 原文地址:https://www.cnblogs.com/mac_arthur/p/1708357.html
Copyright © 2011-2022 走看看