2012-03-08 76 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