将 IBOutlet 连接到选项卡视图中滚动视图中的视图会导致应用程序崩溃。有什么想法吗?
我使用选项卡视图设置创建了一个具有多个选项卡的应用程序。一个选项卡上有一个 UIScrollView,它将 12 个不同的视图加载到 12 个页面中。我尝试向其中一个视图添加按钮和图像视图,但现在它崩溃了。我仔细研究了这里我能找到的每个问题,并尝试了所有建议的解决方案,但无济于事。我得到的错误是著名的“此类与键 foo 的键值编码不兼容”错误。与其他遇到此问题的人一样,如果我断开插座,它就可以正常工作。我已经检查并重新检查了笔尖的类,它指向正确的位置。
所以我什至不知道下一步该去哪里。
我可以发布一些代码,但我什至不知道发布哪些代码会有帮助。我希望有人会说,“嗯,是的,你不能拥有一个包含多个视图的滚动视图,并期望每个页面都有功能。”那会有帮助的!
Page2.h:
#import <UIKit/UIKit.h>
@interface Page2 : UIViewController {
IBOutlet UIImageView *infoImage;
}
@property (保留, 非原子) UIImageView *infoImage;
- (IBAction)showInfo:(id)发送者;
@end
Page2.m:
- (IBAction)showInfo:(id)sender {
// do something please!
}
然后在 nib 文件中,我按住 Ctrl 键从按钮上的“touch-up inside”拖动到“文件所有者”,然后选择“showInfo”...然后按住 Ctrl 键从“文件所有者”向下拖动到我的 UIImageView并选择 infoImage。
崩溃
我还不够酷,无法插入图像: https://i.sstatic.net/KjWhk.png< /a>
I used the tabview setup to create an app that has several tabs. One tab has a UIScrollView on it which loads 12 different views into 12 pages. I tried adding a button and imageview to one of the views and now it crashes. I've pored over every single question on here I can find, and have tried every suggested solution, but to no avail. The error that I get is the famous "this class is not key value coding-compliant for the key foo" error. As with everyone else who had this problem, if I disconnect the outlet, it works fine. I've checked and rechecked the class for the nib and it points to the right place.
So I'm not even sure where to go next.
I could post some code, but I don't even know what code would be helpful to post. I'm hoping someone just says, "Um yeah, you can't have a scroll view with multiple views in it and expect to have functionality on each page." That would be helpful!
Page2.h:
#import <UIKit/UIKit.h>
@interface Page2 : UIViewController {
IBOutlet UIImageView *infoImage;
}
@property (retain, nonatomic) UIImageView *infoImage;
- (IBAction) showInfo:(id)sender;
@end
Page2.m:
- (IBAction)showInfo:(id)sender {
// do something please!
}
Then in the nib file I CTRL-dragged from "touch-up inside" on my button to the Files Owner and chose "showInfo" ... and I CTRL-dragged from Files Owner down to my UIImageView and chose infoImage.
CRASH
I am not cool enough to insert an image: https://i.sstatic.net/KjWhk.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的笔尖中仍然连接着一个插座,但您不再在班级中定义该插座。您会在检查器中看到它已变成灰色。断开它,错误应该消失。
You still have an outlet connected in your nib that you no longer have defined in your class. You'll see in the inspector that it has turned gray. Disconnect it, and the error should be gone.
你是否能够在同一个笔尖文件中创建任何其他出口,因为我曾经遇到过相同的崩溃,并且只有当我复制相同的笔尖时它才得到修复,我已经实现了几乎所有方法来解决它。如果我没记错的话,这个链接可以帮助你 https://discussions .apple.com/thread/2431110?start=0&tstart=0
are u able to create any other outlet in the same Nib file, as i used to get the same crash, and it got fixed only when i duplicated the same nib, i had implemented almost all methods to solve it. If i am not wrong , this link can help you out https://discussions.apple.com/thread/2431110?start=0&tstart=0
我已向您发送了电子邮件并附上了您的项目。希望它现在对你有效。
快乐编码!
I have sent you the email and attached your project. Hope its working at your end now.
Happy Coding!