IBActions 不在文件所有者中?
由于某种原因,我在代码中声明的 IBActions 不在我的文件所有者中。我已经看了一个小时了,但我似乎无法弄清楚。
对此可能有一个非常简单的解释。我可能会觉得自己很愚蠢。提前致谢!
下面是我的代码。
RootViewController.h
#import <UIKit/UIKit.h>
#import "Sqlite.h"
#import "SecondViewController.h"
@interface RootViewController : UITableViewController {
NSMutableArray *listOfItems;
Sqlite *database;
NSTimer *myTimer;
UITextView *myTextField;
}
- (IBAction)addAlbum;
@property(nonatomic, readonly, retain) UILabel *detailTextLabel;
@end
RootViewController.m
#import "RootViewController.h"
#import "TableViewAppDelegate.h"
#import "DetailViewController.h"
@implementation RootViewController
// If a user adds a photo album
- (IBAction)addAlbum {
SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:screen animated:YES];
[screen release];
}
它们确实显示在第一响应程序中,但是当我链接它们时它们不起作用。谢谢!
编辑:我想在不同的 XIB (MainWindow.XIB) 中使用这些操作。我尝试在每个 .h 文件中添加我的操作,但没有一个操作出现在我的 MainWindow.XIB 中。
For some reason my IBActions declared in the code aren't in my File's Owner. I've been looking at this for an hour and I can't seem to figure it out.
There's probably a really simple explanation for this. I am probably going to feel dumb. Thanks in advance!
Below is my code.
RootViewController.h
#import <UIKit/UIKit.h>
#import "Sqlite.h"
#import "SecondViewController.h"
@interface RootViewController : UITableViewController {
NSMutableArray *listOfItems;
Sqlite *database;
NSTimer *myTimer;
UITextView *myTextField;
}
- (IBAction)addAlbum;
@property(nonatomic, readonly, retain) UILabel *detailTextLabel;
@end
RootViewController.m
#import "RootViewController.h"
#import "TableViewAppDelegate.h"
#import "DetailViewController.h"
@implementation RootViewController
// If a user adds a photo album
- (IBAction)addAlbum {
SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:screen animated:YES];
[screen release];
}
They do show up in the First Responder, however when I link them they do not work. Thanks!
Edit: I want to use these actions in a different XIB (MainWindow.XIB). I have tried adding my actions in each of the .h's files but none are showing up in my MainWindow.XIB.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您的 RootViewController.h 已保存。
打开 RootViewController.xib 并选择文件所有者。
确保您的 RootViewController 被选为身份选项卡中的类。
在连接选项卡上,您应该能够验证您的 IBActions。
Make sure your RootViewController.h has been saved.
Open your RootViewController.xib and select File's Owner.
Make sure your RootViewController is selected as the Class in the identity tab.
On the connections tab, you should be able to verify your IBActions.