2011-01-28 71 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]; 

不相信這將解決您的問題,但它可以幫助...