I have a view with three buttons in an iphone app, want to go to another view by clicking a particular button, tried add target method, its working fine but when we go to next view after navigation and click on the back button their it crashes??
Here is my code.
- (void)开发者_运维问答viewDidLoad {
[super viewDidLoad];
helpButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
helpButton.frame= CGRectMake(5, 370, 90, 30);
[helpButton setTitle:[NSString stringWithFormat:@"Help"] forState:UIControlStateNormal];
[helpButton addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
helpButton.tag=1;
[self.view addSubview:helpButton];
}
Please help me
Thanks in advance
when I look at your code, it seems that your helpButton is a class variable... If it is true, you are missing a retain :
helpButton=[[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
not sure it will fix your problem, but it can help...
精彩评论