【问题标题】:viewController no full screenviewController 没有全屏
【发布时间】:2012-12-26 23:26:52
【问题描述】:

任何人都知道如何实现像我们在 iPhone 中点击搜索时那样没有全屏的 viewController 吗? 我希望当用户向上滑动时显示一个 viewController(半高)。 没有转场!!我希望同时显示旧的视图控制器。 提前致谢

【问题讨论】:

    标签: iphone ipad ios5


    【解决方案1】:

    我为整个项目添加了这种类型的功能,我在窗口中添加了 QRView,以便用户从项目的任何视图中向上滑动视图...

    查看我的代码示例..

    只需将UISwipeGestureRecognizer 设置为您想要呈现的第二个视图,如下所示...

     CATransition *animation = [CATransition animation];
        [animation setDelegate:self];   
        [animation setType:kCATransitionFade];
        [animation setDuration:0.5];
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                                      kCAMediaTimingFunctionEaseInEaseOut]];
        [[self.view layer] addAnimation:animation forKey:kAnimationKey];
        UISwipeGestureRecognizer *swipeGesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(addCustomBottomBar)] autorelease];
        swipeGesture.numberOfTouchesRequired = 1;
        swipeGesture.direction = (UISwipeGestureRecognizerDirectionDown);
        [yourViewController.view addGestureRecognizer:swipeGesture];/// use your view name here, its depends on your requirement
        UISwipeGestureRecognizer *swipeGestureTop = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(addCustomBottomBar)] autorelease];
        swipeGestureTop.numberOfTouchesRequired = 1;
        swipeGestureTop.direction = (UISwipeGestureRecognizerDirectionUp);
    
        [yourViewController.view addGestureRecognizer:swipeGestureTop];
    

    当您向上滑动视图时调用此波纹管方法...

    还只需添加一个名为isViewPopBOOL 变量,并在您的viewDidLoad: 方法中将其设置为NO ..

    -(void)addCustomBottomBar{
    
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.window cache:YES];
    
        if (isqrcodepop) {
            isViewPop=NO;
    
            yourViewController.view.frame=CGRectMake(0, 430, 320, 70);
        }
        else{
            isViewPop=YES;
    
            yourViewController.view.frame=CGRectMake(0, 210, 320, 270);
            [self.view bringSubviewToFront:yourViewController.view];
        }
        [UIView commitAnimations];
    }
    

    我希望这个答案对你有所帮助......

    【讨论】:

      【解决方案2】:

      如果它很简单,我会在底部下方的UIViewController 中添加一个UIView - 然后当你点击“搜索”或其他任何东西时,使用动画块将UIView 动画化:

      - (IBAction)btnTouch:(id)sender
      {
              [UIView animateWithDuration:0.3
                                    delay:0.0
                                  options: UIViewAnimationCurveEaseInOut
                               animations:^{
      
                                    //bring searchView up
                                   _searchView.transform = CGAffineTransformMakeTranslation(0, -80);
      
                               }
                               completion:^(BOOL finished){
      
                               }
      
               ];
      }
      

      然后当你完成后,通过使用与这条线相同的动画块将视图推回原点:

      _searchView.transform = CGAffineTransformMakeTranslation(0, 0);
      

      【讨论】:

        【解决方案3】:

        您可以拥有背景视图控制器[self presentViewController:vc animated:YES completion:nil]; 并将您的前视图控制器的框架设置为屏幕的一半。这样,由于前视图的下半部分是透明的,因此您的背景视图控制器仍然可见

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-06-24
          • 2023-03-23
          • 1970-01-01
          • 2021-08-02
          • 2021-01-18
          • 2014-01-23
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多