Interface Builder 将看不到操作方法
我正在尝试将 UIButton 连接到界面生成器中的 IBAction,但 IB 不会显示我定义为连接它的选项的方法。
- (IBAction)someAction:(id)sender;
这就是我在 h 文件中的内容,然后在 M 文件中我有
- (IBAction)someAction:(id)sender{
NSLog(@"Button Tapped."); }
IB 文档连接到我知道的那个类,因为该类也有一个 UIPicker
,并且连接良好。
任何帮助都会很棒,
谢谢, 卡拉汉001。
I am trying to hook up a UIButton
to a IBAction
in interface builder but IB will not show the method that I defined as an option to hook it up to.
- (IBAction)someAction:(id)sender;
That is what I have in the h file, and then in the M file I have
- (IBAction)someAction:(id)sender{
NSLog(@"Button Tapped."); }
The IB Document is connected to that class i know because that class also has a UIPicker
, and that connects fine.
Any help would be brilliant on this,
Thanks,
Callaghan001.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我通过从 Interface Builder 手动读取类文件解决了这个问题。只需执行文件 ->读课->找到您在其中定义 IBAction 的 .h 文件。 ->打开!
然后界面构建器会说“解析了一个类文件”之类的内容
I fixed this problem by reading in the Class file manually from Interface Builder. Just do File -> Read Class -> find the .h file you defined the IBAction in. -> open!
Then Interface builder will say something like "one Class file parsed"
确保您实际上正在连接按钮事件的处理程序(可能在内部进行触摸)而不是按钮本身。因此,不要直接从按钮拖动,而是按住 Ctrl 键单击按钮以查看其连接,然后从其 touch up 内部事件拖动到目标,或者按住 Ctrl 键单击目标,找到操作,然后从该操作拖动到按钮。如果在这些情况下操作没有显示在目标上,并且您确定界面构建器知道它是什么类,那么我会感到困惑。
Make sure you're actually wiring up the handler for the button's event (probably touch up inside) and not the button itself. So instead of dragging directly from the button, either ctrl-click the button to see its connections and drag from its touch up inside event to the target, or ctrl-click the target, find the action, and drag from that to the button. If the action doesn't show up on the target in these cases, and you're sure interface builder knows what class it is, then I'm baffled.
同样的问题,读取类文件并没有解决它,但是将控制器身份检查器中的类名称从 UIViewController 更改为正确的子类名称却解决了这个问题。
same problem, reading class file in didn't fix it but changing the class name in the controller identity inspector from UIViewController to the correct subclass name did.
尝试在 .h 文件中添加
-(IBAction)testFunction:(id)sender;
。这对我有用。
try adding
-(IBAction)testFunction:(id)sender;
in the .h file.It worked for me.
我遇到了这个问题,重新启动 Xcode 并没有解决它。
为我解决的问题是:
文件所有者
身份检查器
(在实用程序
下,右侧面板)。自定义类
部分下,只需选择文本字段(其中应显示您的自定义UIViewController
子类名称)并按“Enter”。I had a this problem and restarting Xcode did not solve it.
What solved it for me was:
File Owner
Identity Inspector
(underUtilities
, right hand side panel).Custom Class
section, just select the text field (where your customUIViewController
sub-class name should be displayed) and hit 'Enter'.我认为你的实施必须是
I think your implementation must be