Custom back button click event on pushed view controller
- by TechFusion
Hello,
I have pushed view controller and load WebView and Custom rectangular rounded button on right down left corner into view using programmatic way.
-(void)loadView {
        CGRect frame = CGRectMake(0.0, 0.0, 480, 320);
    WebView = [[[UIWebView alloc] initWithFrame:frame] autorelease];
    WebView.backgroundColor = [UIColor whiteColor];
    WebView.scalesPageToFit = YES;
    WebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin);
    WebView.autoresizesSubviews = YES; 
    WebView.exclusiveTouch = YES;
    WebView.clearsContextBeforeDrawing = YES;
 self.roundedButtonType = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
 self.roundedButtonType.frame = CGRectMake(416.0, 270.0, 44, 19);
 [self.roundedButtonType setTitle:@"Back" forState:UIControlStateNormal];
 self.roundedButtonType.backgroundColor = [UIColor grayColor];
 [self.roundedButtonType addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
 self.view = WebView;
 [self.view addSubview: self.roundedButtonType ]; 
 [WebView release]; 
}
This is action that I have added as back button of navigation.
-(void)back:(id)sender{
 [self.navigationController popViewControllerAnimated:YES];
}
-(void)viewDidUnload{
 self.WebView = nil;
 self.roundedButtonType = nil;
}
-(void)dealloc{
 [roundedButtonType release];
 [super dealloc];
}
Here, When Back button click then it is showing previous view but application got stuck in that view and GDB shows Program received signal :EXC_BAD_ACCESS message.
how resolve this issue?
Thanks,