• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

objective-c - EXC_BAD_ACCESS 切换到 ARC 时出错

[复制链接]
菜鸟教程小白 发表于 2022-12-11 21:47:32 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我在表格 View 单元格中有一个文本字段,我想分配一个自定义输入键盘。我可以让键盘显示出来,但似乎没有连接相应的 Controller 类。当我按下任何按钮时,我会收到 EXC_BAD_ACCESS 错误或“无法识别的选择器”错误。

这是我将表格 View 单元格的文本字段绑定(bind)到自定义输入键盘的代码

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

我有绑定(bind)到 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)buttonPressedid)sender;
-(IBAction)buttonDonePressedid)sender;
-(IBAction)buttonDelPressedid)sender;


@end

以及相关的实现(为简洁起见,我已经删除了操作方法的内容,只留下了我的调试日志):

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

@implementation CustomNumberPadViewController

@synthesize equationViewController;

- (id)initWithNibNameNSString *)nibNameOrNil bundleNSBundle *)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) viewWillAppearBOOL)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)buttonPressedid)sender{
    NSLog(@"61-CNPVC");    
}
-(IBAction)buttonDonePressedid)sender{
    NSLog(@"117-CNPVC");
}
-(IBAction)buttonDelPressedid)sender{
    NSLog(@"125-CNPVC");
}
@end



Best Answer-推荐答案


我认为您需要保留 CustomNumberPadViewController,方法是使用 addChildViewController 添加它或将其分配给属性。

尝试使用 zombies enabled 进行调试.

关于objective-c - EXC_BAD_ACCESS 切换到 ARC 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9623473/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap