如何与多个目标c类共享xib文件
我是ios开发的新手,所以我不知道这个问题是否正确。 我想在基于视图的应用程序模板中从单独的 uiview 类创建 uibutton 。 如果有人知道,请澄清我的问题。
I am new in ios development, so i don't know this question is correct or not.
I want to create a uibutton from a separate uiview class in view based application template.
if anybody know ,please clear my question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这很容易做到。这段代码片段应该有帮助;
有几点需要注意。我的 xib 中有一个 rollDataViewFPO(FPO 的意思是“仅用于位置”)。我使用 FPO 框架来定位刚刚加载的对象。这样我就可以将它定位在我的 xib 上,而不是我的代码上。
另请注意,我调用了自己的 initWithType 方法。我的 TiltData 对象可用于显示滚动或俯仰数据,我需要告诉它们它们是什么类型。
That's pretty easy to do. This code snippet should help;
There are a few things to note. I have a rollDataViewFPO (FPO means "for position only") in my xib. I use the FPO frame for positioning the object I just loaded. This way I can position it my xib, not my code.
Also note that I call my own initWithType method. My TiltData objects can be used to show Roll or Pitch data, and I need to tell them what type they are.
添加一个新的File ObjectiveC类,使其成为UIView的子类(此处假设名称:SubView)。
如果您不想使用 UIViewController 类的视图,则只需在
UiViewController 的 xib 中选择视图,然后在检查器窗口中将类名称更改为 SubView。将 UIButton
放入该视图中并执行您想要的任何操作。如果您想要单独View 然后只需
从菜单栏中拖放 UIView 并将其作为出口连接到 ViewController 类,并将
UIView 类的名称更改为 SubView。
Add a newFile ObjectiveC class make it as SubClass of UIView(assume name here: SubView).
if you doesn't want to use the view of UIViewController Class then just select the view in xib
of UiViewController and change the class name to SubView in inspector window.put the UIButton
in that view and do anything what you want.If you want Separate View then simply drag and
drop UIView from menu bar and connect that as an outlet to your ViewController Class and
change name of UIView class to SubView.