UIBarButtonItem 的新视图? [英] New view from UIBarButtonItem?

查看:12
本文介绍了UIBarButtonItem 的新视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我之前看到过与此类似的问题,但没有帮助.我也阅读了 Apple 的文档,但我不明白我哪里出错了.AFAIK 我按逻辑做了所有事情,但是当我单击 UItoolbar 覆盖层上的完成按钮时,可以按下该按钮,但它什么也不做.这显然意味着它无法确认编写的代码.但是如何?

So I've seen previous questions similar to this but they were of no help. I've read Apple's documentation too but I could not understand where I've gone wrong. AFAIK I did everything logically, but when I click on my done button on an UItoolbar overlay, the button can be pushed but it does not do anything. This obviously means it fails to acknowledge the written code. But how?

当在我的 UIToolBar 上单击完成按钮时,我想调出TableViewController"的 .nib.但是下面的内容不允许单击以显示新视图.我该如何纠正?请告诉我哪里出了问题,应该更换什么以及为什么.

I want to bring up the .nib of "TableViewController" when a done button is clicked on my UIToolBar. But the below isn't allowing the click to bring up a new view. How do I rectify this? Please show me where I went wrong and what should be replaced and why.

-(void)doneButtonPressed {

TableViewController *UIView = [[TableViewController alloc]
initWithNibName:@"TableViewController" bundle:nil];
UIView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:UIView animated:YES];
[UIView release];

}

推荐答案

哇,这里发生了一些奇怪的事情.在您的第一行中,您正确分配和启动了 TableViewController 实例,但您没有为该实例提供唯一名称.你用另一个类的名字来命名它,这肯定会引起问题.事实上,我很惊讶它没有通过错误.

Whoa, you've got some bizarre stuff going on here. In your first line, you're allocating and initiating the TableViewController instance correctly, but you're not giving that instance a unique name. You're naming it with another class's name, which is bound to stir up problems. In fact, I'm surprised it didn't through an error.

请尝试以下操作:

TableViewController *tableView = [[TableViewController alloc]
initWithNibName:@"TableViewController" bundle:nil];
tableView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:tableView animated:YES];

现在,您的 TableViewController 实例有一个唯一的名称,该名称在方法的其余部分都被引用.澄清一下——UIView 是另一个类名,因此不能用作对象实例的名称.

Now, your TableViewController instance has a unique name that is referenced throughout the rest of the method. Just to be clear--UIView is another class name, and therefore cannot be used as the name of an instance of an object.

此外,请务必将按钮的选择器 doneButtonPressed: 添加到其视图控制器的 .h 文件中.此外,如果您愿意,您可以在函数的开头抛出一个 NSLog() 调用,以确保它没有被调用(或者可能是).

Additionally, be sure to add your button's selector doneButtonPressed: to your .h file of its view controller. Also, if you like you can toss an NSLog() call in the beginning of the function just to be sure it isn't (or perhaps is) being called.

这篇关于UIBarButtonItem 的新视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆