Iphone 如何隐藏uiview用户不使用该视图?
我有一个类似快捷方式的视图,带有一些按钮。现在,当我单击快捷按钮时,快捷方式视图显示现在我希望用户不触摸视图如何在8秒后隐藏快捷方式视图,以及在8秒前触摸视图。您可以使用UIView动画将视图移出屏幕Iphone 如何隐藏uiview用户不使用该视图?,iphone,ios5,ios4,Iphone,Ios5,Ios4,我有一个类似快捷方式的视图,带有一些按钮。现在,当我单击快捷按钮时,快捷方式视图显示现在我希望用户不触摸视图如何在8秒后隐藏快捷方式视图,以及在8秒前触摸视图。您可以使用UIView动画将视图移出屏幕 [UIView animateWithDuration:0.333f delay:8.0f options:UIViewAnimationCurveEaseOut anima
[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点
要把它移回去,好吧,你就明白了;) 您可以使用-(void)performSelector:(SEL)一个带有object:(id)argument afterDelay:(NSTimeInterval)delay
和+(void)cancelPreviousPerformRequestsWithTarget:(id)ataTarget
方法的选择器
-(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
...
}