I'm doing application with different Viewcontroller for different set of screens. I have button click, playing video and load html pages etc. If i open the app and my app in second view controller, then i haven't do anything within 1minutes for example any click event or any touch event in app, automatically Can i redirect to first view controller? Does it possible?
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
video=[[VideoViewController alloc]init];
[self.navigationController.navigationBar setHidden:YES];
bgImg=[[UIImageView alloc]init];
[bgImg setFrame:CGRectMake(0,0,1024,768)];
[bgImg setImage:[UIImage imageNamed:@"home_bg.png"]];
[bgImg setUserInteractionEnabled:YES];
[self.view addSubview:bgImg];
video_play=[UIButton buttonWithType:UIButtonTypeCustom];
// [info_btn setFrame:CGRectMake(240,10 ,13, 24)];
[video_play setFrame:CGRectMake(118,300,362,202)];
[video_play setImage:[UIImage imageNamed:@"video.png"] forState:UIControlStateNormal];
[video_play addTarget:self action:@selector(watchvideo:) forControlEvents:UIControlEventTouchUpInside];
//[rhymesbgImg addSubview:info_btn];
[bgImg addSubview:video_play];
watch_video=[UIButton buttonWithType:UIButtonTypeCustom];
// [info_btn setFrame:CGRectMake(240,10 ,13, 24)];
[watch_video setFrame:CGRectMake(180,600,232,60)];
[watch_video setImage:[UIImage imageNamed:@"watch-video.png"] forState:UIControlStateNormal];
[watch_video addTarget:self action:@selector(watchvideo:) forControlEvents:UIControlEventTouchUpInside];
//[rhymesbgImg addSubview:info_btn];
[bgImg addSubview:watch_video];
[self performSelector:@selector(goToRootViewController) withObject:nil afterDelay:20.0];
}
Click Event for Button:
-(void)watchvideo:(id)sender{
// [self performSelector:@selector(goToRootViewController) withObject:nil afterDelay:20.0];
[bgImg setHidden:YES];
[watch_video setHidden:YES];
[estimate_yoursaving setHidden:YES];
NSString *pathToBundle = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:pathToBundle];
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"html"];
NSString *htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
//CGRect fullScreenRect=[[UIScreen mainScreen]applicationFrame];
web=[[UIWebView alloc]initWithFrame:CGRectMake(172, 210, 680, 380)];
[web loadHTMLString:htmlString baseURL:baseURL];
}
-(void)estimatesavings:(id)sender{
// [self performSelector:@selector(goToRootViewController) withObject:nil afterDelay:20.0];
[web loadHTMLString:nil baseURL:nil];
NSString *pathToBundle = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:pathToBundle];
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSString *htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
//CGRect fullScreenRect=[[UIScreen mainScreen]applicationFrame];
web_estimate=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 1024, 768)];
[web_estimate loadHTMLString:htmlString baseURL:baseURL];
web_estimate.delegate=self;
[self.view addSubview:web_estimate];
}
touch Event:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
isTouched = YES;
NSLog(@"Touches happening");
}
- (void)goToRootViewController
{
if (isTouched == NO) {
// [self.navigationController popToRootViewControllerAnimated:YES];
NSLog(@"Touches Not Happening");
[bgImg setHidden:NO];
[watch_video setHidden:NO];
[estimate_yoursaving setHidden:NO];
[web setHidden:YES];
[web_estimate setHidden:YES];
}
}