【问题标题】:how to hide the uiview user does not use the view?如何隐藏uiview用户不使用的视图?
【发布时间】:2012-06-07 18:58:27
【问题描述】:

我有一个视图,例如带有一些按钮的快捷方式视图。现在,当我单击快捷方式按钮时,会出现快捷方式视图,我希望用户不触摸视图,如何在 8 秒后隐藏快捷方式视图,并且用户在 8 秒前触摸视图,它将出现。

【问题讨论】:

    标签: iphone ios5 ios4


    【解决方案1】:

    您可以使用 UIView 动画并将视图移出屏幕

    [UIView animateWithDuration:0.333f 
                          delay:8.0f 
                        options:UIViewAnimationCurveEaseOut 
                     animations:^(void) {
                          myView.transform = CGAffineTransformMakeTranslation(0,self.view.frame.size.height);
                               }
                     completion:nil];
    

    在此示例中,我将您的视图移动到屏幕底部,CGAffineTransformMakeTranslation(x,y) 将您的视图框架移动给定的 x 和 y 点

    然后把它移回来,好吧,你明白了;)

    【讨论】:

      【解决方案2】:

      您可以使用- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay+ (void)cancelPreviousPerformRequestsWithTarget:(id)aTarget 方法

      -(void)showShortcuts
      {
          // all the code you need to show your shortcuts view
          ...
          [self perfornSelector:@selector(hideShortcuts) withObject:nil afterDelay:8.0];
      }
      
      -(void)hideShortcuts
      {
      // all the code you need to hide your shortcuts view
      ...
      }
      
      -(void)shortcutPressed:(id) shortcut
      {
          [NSObject cancelPreviousPerformRequestsWithTarget:self];
          // code your shortcut is supposed to trigger
          ...
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-06-07
        • 1970-01-01
        • 2011-07-22
        • 1970-01-01
        • 1970-01-01
        • 2021-03-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多