Custom back button click event on pushed view controller

Posted by TechFusion on Stack Overflow See other posts from Stack Overflow or by TechFusion
Published on 2010-04-03T14:33:33Z Indexed on 2010/04/03 14:43 UTC
Read the original article Hit count: 324

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,

© Stack Overflow or respective owner

Related posts about uinavigationcontroller

Related posts about uibutton