2011-01-28 43 views
0

我有一个在iPhone应用程序三个按钮的观点,希望通过点击一个特定的按钮转到另一种观点认为,试图添加目标的方法,它工作正常,但是当我们去到下一个视图导航后并点击后退按钮他们崩溃?应用在特定点崩溃

这是我的代码。

- (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]; 
} 

请帮我

在此先感谢

+1

这里粘贴一些代码,过去e控制台输出。 – 2011-01-28 12:00:40

+0

- (无效)viewDidLoad中{ \t \t [超级viewDidLoad中]; \t helpButton = [UIButton的buttonWithType:UIButtonTypeRoundedRect]; \t helpButton.frame = CGRectMake(5,370,90,30); \t [helpButton的setTitle:[的NSString stringWithFormat:@ “帮助”] forState:UIControlStateNormal]; [helpButton addTarget:自动作:@selector(btnClicked :) forControlEvents:UIControlEventTouchUpInside]; \t helpButton.tag = 1; \t [self.view addSubview:helpButton]; – User 2011-01-28 12:04:19

回答

0

,当我看着你的代码,看来你helpButton是一个类变量...如果这是真的,你缺少一个保留:

helpButton=[[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; 

不相信这将解决您的问题,但它可以帮助...