<small id='DifUT'></small><noframes id='DifUT'>

      <i id='DifUT'><tr id='DifUT'><dt id='DifUT'><q id='DifUT'><span id='DifUT'><b id='DifUT'><form id='DifUT'><ins id='DifUT'></ins><ul id='DifUT'></ul><sub id='DifUT'></sub></form><legend id='DifUT'></legend><bdo id='DifUT'><pre id='DifUT'><center id='DifUT'></center></pre></bdo></b><th id='DifUT'></th></span></q></dt></tr></i><div id='DifUT'><tfoot id='DifUT'></tfoot><dl id='DifUT'><fieldset id='DifUT'></fieldset></dl></div>
        <bdo id='DifUT'></bdo><ul id='DifUT'></ul>

      1. <legend id='DifUT'><style id='DifUT'><dir id='DifUT'><q id='DifUT'></q></dir></style></legend>

      2. <tfoot id='DifUT'></tfoot>
      3. 在 iOS 5 中下拉 UIView

        时间:2023-05-31

        <small id='Eb1Cg'></small><noframes id='Eb1Cg'>

            • <bdo id='Eb1Cg'></bdo><ul id='Eb1Cg'></ul>
              <tfoot id='Eb1Cg'></tfoot>
              <i id='Eb1Cg'><tr id='Eb1Cg'><dt id='Eb1Cg'><q id='Eb1Cg'><span id='Eb1Cg'><b id='Eb1Cg'><form id='Eb1Cg'><ins id='Eb1Cg'></ins><ul id='Eb1Cg'></ul><sub id='Eb1Cg'></sub></form><legend id='Eb1Cg'></legend><bdo id='Eb1Cg'><pre id='Eb1Cg'><center id='Eb1Cg'></center></pre></bdo></b><th id='Eb1Cg'></th></span></q></dt></tr></i><div id='Eb1Cg'><tfoot id='Eb1Cg'></tfoot><dl id='Eb1Cg'><fieldset id='Eb1Cg'></fieldset></dl></div>

              <legend id='Eb1Cg'><style id='Eb1Cg'><dir id='Eb1Cg'><q id='Eb1Cg'></q></dir></style></legend>
                    <tbody id='Eb1Cg'></tbody>
                  本文介绍了在 iOS 5 中下拉 UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我在我的 iPhone 应用中看到状态栏上有一个手势可以访问通知中心.如何在我的应用程序中实现这种转换?我认为这是通过滑动手势识别器完成的,但是如何包含从上到下的滑动手势(如何将通知中心拖动到其完整过渡)?是否有任何示例代码或可以帮助我做到这一点的东西?提前谢谢

                  I saw in my iPhone app that there is a gesture on the status bar which can access Notification Center. How can I implement that kind of transition in my app?. I think this is done with the swipe gesture recognizer, but how do I include a swipe gesture from top to bottom (how you can drag the Notification Center through its full transition)? Is there any sample code or something that can help me do this? Thaks in advance

                  推荐答案

                  应该很容易做到.假设您有一个 UIView (mainView),您想从中触发下拉操作.

                  Should be easy to do. Let's say you have a UIView (mainView) from which you want to trigger the pull down thing.

                  1. 在 mainView 可见区域的顶部外部放置一个子视图(pulldownView).
                  2. mainView 上实现 touchesBegan 并检查触摸是否在前 30 个像素(或点)中.
                  3. 在你检查的地方实现 touchesMoved,如果移动方向向下并且 pulldownView 不可见,如果是这样,将 pulldownView 向下拖动到可见区域主视图或检查移动方向是否向上并且 pulldownView 可见,如果是,则向上推出可见区域.
                  4. 实现 touchesEnd,通过检查 pulldownView 的移动方向来结束拖动或推动移动.
                  1. Put a subview (pulldownView) on mainView top-outside of visible area.
                  2. Implement touchesBegan on mainView and check if the touch is in the top 30 pixels (or points).
                  3. Implement touchesMoved where you check, if move direction is down and pulldownView not visible and if so drag the pulldownView down into visible area of main view or check if move direction is up and pulldownView visible and if so push upwards out of visible area.
                  4. Implement touchesEnd where you end the drag or push movement by checking in which direction the pulldownView was moved.

                  这里有一些示例代码.未经测试,可能包含拼写错误,可能无法编译,但应该包含所需的基本部分.

                  Here's some sample code. Untested, may contain typos, maybe won't compile, but should contain the essential part needed.

                  //... inside mainView impl:
                  -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
                  {
                    UITouch *touch = (UITouch *)[touches anyObject];
                    start = [touch locationInView:self.superview].y;
                    if(start > 30 && pulldownView.center.y < 0)//touch was not in upper area of view AND pulldownView not visible
                    {
                      start = -1; //start is a CGFloat member of this view
                    }
                  }
                  
                  -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
                  {
                    if(start < 0)
                    {
                      return;
                    }
                    UITouch *touch = (UITouch *)[touches anyObject];
                    CGFloat now = [touch locationInView:self.superview].y;
                    CGFloat diff = now - start;
                    directionUp = diff < 0;//directionUp is a BOOL member of this view
                    float nuCenterY = pulldownView.center.y + diff;
                    pulldownView.center = CGPointMake(pulldownView.center.x, nuCenterY);
                    start = now;
                  }
                  
                  
                  -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
                  {
                    if (directionUp)
                    {
                      //animate pulldownView out of visibel area
                      [UIView animateWithDuration:.3 animations:^{pulldownView.center = CGPointMake(pulldownView.center.x, -roundf(pulldownView.bounds.size.height/2.));}];
                    }
                    else if(start>=0)
                    {
                      //animate pulldownView with top to mainviews top
                      [UIView animateWithDuration:.3 animations:^{pulldownView.center = CGPointMake(pulldownView.center.x, roundf(pulldownView.bounds.size.height/2.));}];
                    }
                  }
                  

                  这篇关于在 iOS 5 中下拉 UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何通过单独提供密钥文件来播放 m3u8 加密播放 下一篇:iPhone SDK 6 启动带有语音导航方向的地图

                  相关文章

                  最新文章

                  1. <legend id='B1Yfq'><style id='B1Yfq'><dir id='B1Yfq'><q id='B1Yfq'></q></dir></style></legend>

                    <small id='B1Yfq'></small><noframes id='B1Yfq'>

                  2. <i id='B1Yfq'><tr id='B1Yfq'><dt id='B1Yfq'><q id='B1Yfq'><span id='B1Yfq'><b id='B1Yfq'><form id='B1Yfq'><ins id='B1Yfq'></ins><ul id='B1Yfq'></ul><sub id='B1Yfq'></sub></form><legend id='B1Yfq'></legend><bdo id='B1Yfq'><pre id='B1Yfq'><center id='B1Yfq'></center></pre></bdo></b><th id='B1Yfq'></th></span></q></dt></tr></i><div id='B1Yfq'><tfoot id='B1Yfq'></tfoot><dl id='B1Yfq'><fieldset id='B1Yfq'></fieldset></dl></div>

                        <bdo id='B1Yfq'></bdo><ul id='B1Yfq'></ul>

                    1. <tfoot id='B1Yfq'></tfoot>