我可以**同时**使用具有相同所有者类的多个 nib 文件吗?
我可以同时加载具有相同所有者类的多个 nib 文件吗?
那么我可以从不同的笔尖加载纸张吗?
我目前正在使用 NSBundle:
[NSBundle loadNibNamed:@"nib1" owner:self];
[NSBundle loadNibNamed:@"nib2" owner:self];
但我收到此错误消息”
<Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 3387
<Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
<Error>: kCGErrorIllegalArgument: CGSOrderWindowListWithGroups: invalid window ID (3387)
谢谢
Can I load multiple nibs files with the same owner class at the same time ?
So I can load sheets from different nibs ?
I'm currently using NSBundle:
[NSBundle loadNibNamed:@"nib1" owner:self];
[NSBundle loadNibNamed:@"nib2" owner:self];
But I get this error message"
<Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 3387
<Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
<Error>: kCGErrorIllegalArgument: CGSOrderWindowListWithGroups: invalid window ID (3387)
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
加载多个 nib 当然是可能的,但您需要确保两个 nib 文件中的绑定都是正确的。如果 nib 文件仅包含视图,请为每个 NSView 创建一个 IBOutlet 并以这种方式分隔 nib。
Loading several nibs is of course possible, but you need to make sure your bindings are right in both nib files. If the nib files are simply containing views, make an IBOutlet for each NSView and separate the nibs that way.
尝试这种方式:为视图控制器创建一个主视图,您需要的大小和空。然后创建一个从 UIView 派生的新类(即:AlternativeView)并将 XIB 中的视图类设置为这个新类。
在 AlternativeView.m 中放置一个像这样的方法:
现在您可以使用 +(id)newAlternativeView:(NSString*)nibName 创建视图,并将它们添加/删除到视图控制器的主视图中。通过这种方式,您甚至可以将视图与由不同 xib 加载的许多子视图组合在一起。
Try this way: create a main view for the viewcontroller, the size you need it and empty. Then create a new class derived from UIView (i.e.: AlternativeView) and set the view class in your XIBs as this new class.
In the AlternativeView.m put a method like this:
Now you can create your view by using +(id)newAlternativeView:(NSString*)nibName and add/remove them to the main view of the viewcontroller. In this way you can even compose the view with many subviews loaded by different xib.