我正在为iPhone和iPad开发应用程序。在这里,我想在(0.5)时间间隔加载uiwebview中的URL。完成加载Web视图后,我想导航到下一个视图。我已经通过将导航编码添加到[webViewDidFinishLoad:]来实现这一点,并且它工作正常。现在,我的客户需要在视图中添加一个按钮,以便在用户不想留在Web视图中(0.5)秒时进行导航。
我应该在延迟后使用单独的(选择器:)动作:0.5和圆形矩形按钮?
if it so, how can i implement this,
I googled it, but could not find the solution. Any help appreciated. Thanks.
答案 0 :(得分:1)
非常感谢您的回复。在这里,我实施了" NSTimer"概念而不是使用" PerformSelector:afterDelay"。这是代码,
timer = [NSTimer scheduledTimerWithTimeInterval: 5.0
target: self
selector: @selector(goToNextView)
userInfo: nil
repeats: NO];
// here i have set the time interval of '5.0' and after that taking into next view.
-(void)goToNextView
{
newtest15 *nt=[[newtest15 alloc]init];
[self.navigationController pushViewController:nt animated:YES];
}
我在工具栏上有一个按钮,用于导航到下一个视图。
-(IBAction)btn:(id)sender{
if ( [timer isValid])
{
[timer invalidate], timer=nil;
}
newtest15 *nt=[[newtest15 alloc]init];
[self.navigationController pushViewController:nt animated:YES];
}
/* here, when the user wants to move to next view before the time interval of '5', and presses the button at the bottom, this action will be performed, it will invalidate the timer and navigate to the next view*/
答案 1 :(得分:0)
您可以在viewdidload方法中实现performSelector:withObject:afterDelay:0.5秒。 然后定义一个方法,显示警报消息按钮不在或离开页面。然后在警报视图按钮上进行一些编码