rightBarButtonItem 上的访问错误 & “macosx_kill_inferior_safe

发布于 2024-10-16 07:22:55 字数 1079 浏览 3 评论 0原文

按右栏按钮,显示 NCFSString 无法识别的选择器。重新启动时,我没有得到任何有用的堆栈跟踪。

 -(void)nextIntroStage{
_introStage++;
if (_introStage < _maxIntro) {
    [self showIntroPicture];
} else {
    [self finishedIntro];
}

奇怪的是

 -(void)viewDidLoad {
[super viewDidLoad];
_introStage = 0;
_maxIntro = 3;

UIBarButtonItem *nextButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" 
                                                               style:UIBarButtonItemStyleBordered 
                                                              target:self
                                                              action:@selector(nextIntroStage)];
self.navigationItem.rightBarButtonItem = nextButton;

,将其切换到 leftBarButtonitem 并得到“NSURL nextIntroStage”..但我没有在应用程序中的任何地方使用 NSURL。当然是某种内存问题,但是什么?

我能想到的唯一相关的事情是在我正在做的应用程序委托中

    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:viewController];
[window addSubview:nc.view];
[window makeKeyAndVisible];
[nc release];

Pressinsg the right bar button, Showed NCFSString unrecognized selector.. on restarting, I get no helpful stack trace.

 -(void)nextIntroStage{
_introStage++;
if (_introStage < _maxIntro) {
    [self showIntroPicture];
} else {
    [self finishedIntro];
}

}

 -(void)viewDidLoad {
[super viewDidLoad];
_introStage = 0;
_maxIntro = 3;

UIBarButtonItem *nextButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" 
                                                               style:UIBarButtonItemStyleBordered 
                                                              target:self
                                                              action:@selector(nextIntroStage)];
self.navigationItem.rightBarButtonItem = nextButton;

Strange, switched it to leftBarButtonitem and am getting "NSURL nextIntroStage".. but I'm not using an NSURL anywhere in my app. Some kind of memory issue, sure, but what?

Only relevant thing I can think of is in my app delegate I'm doing

    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:viewController];
[window addSubview:nc.view];
[window makeKeyAndVisible];
[nc release];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离笑几人歌 2024-10-23 07:22:55

addSubview: 方法仅保留您添加的视图,而不保留导航控制器。通过使用[nc release]释放该导航控制器,您实际上是在销毁该视图的navigationController。

nc 的声明移至您的 .h,在 didFinishLaunchingWithOptions 中照常初始化它,并在 dealloc 中释放它。

The addSubview: method only retains the view you have added, not the navigation controller. By releasing that navigation controller with [nc release], you are essentially destroying that view's navigationController.

Move the declaration for nc to your .h, initialise it as usual in your didFinishLaunchingWithOptions and release it in your dealloc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文