2012-03-08 77 views
2

時,我有一個tableview中細胞的文本字段,我想指定自定義輸入鍵盤。我可以讓鍵盤出現,但似乎相應的控制器類沒有連接。當我按下任何按鈕時,出現EXC_BAD_ACCESS錯誤或「無法識別的選擇器」錯誤。EXC_BAD_ACCESS錯誤切換到ARC

這裏是我綁的tableview細胞的文本字段的自定義輸入鍵盤代碼

CustomNumberPadViewController *calcKeyboard = [[CustomNumberPadViewController alloc] initWithNibName:@"CustomNumberPadView" bundle:nil]; 
calcKeyboard.equationViewController = self; 
cell.variableValue.inputView = calcKeyboard.view; 

我有動作方法綁在calkKeyboard的按鈕,當我按下按鈕,這些方法都沒有被稱爲。我甚至實例化了一個「viewWillAppear」方法,當鍵盤出現時也不會調用它。

我已經檢查了類數字小的,它被連接到CustomNumberPadViewController,其包含上述方法。

這裏是我的CustomNumberPadViewController代碼:

#import <UIKit/UIKit.h> 
#import "EquationViewController.h" 
@class EquationViewController; 


@interface CustomNumberPadViewController : UIViewController <UITextFieldDelegate>{ 
EquationViewController *equationViewController; 
} 

@property (nonatomic, strong) EquationViewController *equationViewController; 

-(IBAction)buttonPressed:(id)sender; 
-(IBAction)buttonDonePressed:(id)sender; 
-(IBAction)buttonDelPressed:(id)sender; 


@end 

和相關的實施(爲簡便起見,我切出的動作方法的膽量和剛剛離開我的調試日誌):

#import "CustomNumberPadViewController.h" 
#import "VariableCellController.h" 

@implementation CustomNumberPadViewController 

@synthesize equationViewController; 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
     if (self) { 
    } 
    return self; 
} 

- (void)didReceiveMemoryWarning 
{ 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

-(void) viewWillAppear:(BOOL)animated 
{ 
    UIColor *backgroundPatern = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"calculatorBackground.png"]]; 
    self.view.backgroundColor = backgroundPatern; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

#pragma mark - Action Methods 

-(IBAction)buttonPressed:(id)sender{ 
    NSLog(@"61-CNPVC");  
} 
-(IBAction)buttonDonePressed:(id)sender{ 
    NSLog(@"117-CNPVC"); 
} 
-(IBAction)buttonDelPressed:(id)sender{ 
    NSLog(@"125-CNPVC"); 
} 
@end 

回答

2

我認爲您需要保留CustomNumberPadViewController,方法是將其與addChildViewController一起添加或將其分配給屬性。

嘗試用zombies enabled調試它。

+0

這樣做,我試圖讓它成爲一個屬性,但必須弄糟一些語法,並繼續其他一些想法。萬分感謝。有趣的是,當我沒有使用ARC時,我沒有這個問題。但我想我確實有內存泄漏... – Jbryson 2012-03-08 20:11:53