.net用户控件X $ C $等价的C [英] .Net UserControl XCode equivalent

查看:199
本文介绍了.net用户控件X $ C $等价的C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经习惯了在Visual Studio的用户控制......我想知道是否有一种方法可以做到这一点英寸x code ...

I'm used to create "user controls" in Visual Studio... and i was wondering if there is a way to do that in XCode...

我一直在环顾四周,有的人告诉我建立一个插件......那声音,而太复杂构建一个简单的可重复使用的文本框 - >按钮 - >标签......在VS我可以只创建 - >用户控制,程序和拖/放的控制,如果它是一个简单的按钮...它真的是这么简单......

I've been looking around and some people was telling me to build a plugin... that sound rather too complicated to build a simple reusable "text box -> button -> label"... In VS i can just create -> User Control, program and drag/drop the control as if it was a simple button... and it really is as simple as that...

任何想法?

推荐答案

无论是厦门国际银行(界面构建视图)或类继承自UIView的等同于用户的控制。他们的方法来聚集亚意见(想想视图和子视图 - 不是控制)。

Either a XIB (interface builder view) or a class that inherits from UIView are equivalent to a user control. They are ways to aggregate sub views (think views and sub-views - not controls).

在内部界面生成器的厦门国际银行,你可以添加其他控件(拖动从库),地点在视图中。文件,新文件,iOS系统中,用户界面​​,查看下。此等问题涵盖了:

Inside the XIB in interface builder, you can add other controls (drag from the library) and place in the view. File, New File, under iOS, User Interface, View. This SO question covers that:

怎样关联笔尖(的.xib)文件与一个UIView?

如果你想以编程方式做到这一点,创建一个继承自UIView的一个新的Objective-C类。在viewDidLoad中,可以通过编程方式创建其他控件,把它们。

If you want to do it programmatically, create a new objective-c class that inherits from UIView. In viewDidLoad, you can programmatically create other controls and place them.

下面是一个编程教程:

http://www.raywenderlich.com/1768/how-to-make-a-custom-uiview-a-5-star-rating-view

最后,在总量控制一个常见的​​类型是一个UITableViewCell在表使用。这里有两种编程和IB创建自定义的UITableView细胞的教程。

Finally, a common type of 'aggregate control' is a UITableViewCell for use in tables. Here's a tutorial on creating custom UITableView cells both programmatically and with IB.

http://www.e-string.com/content/定制uitableviewcells接口建设者

从苹果这些指南都不错阅读:

These guides from Apple are good to read:

<一个href="http://developer.apple.com/library/ios/#DOCUMENTATION/WindowsViews/Conceptual/ViewPG_iPhoneOS/Introduction/Introduction.html" rel="nofollow">http://developer.apple.com/library/ios/#DOCUMENTATION/WindowsViews/Conceptual/ViewPG_iPhoneOS/Introduction/Introduction.html

<一个href="http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/BasicViewControllers/BasicViewControllers.html" rel="nofollow">http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/BasicViewControllers/BasicViewControllers.html

编辑:

我只是想这...

添加一个XIB到您的项目,如上所述。添加一些控制它,你要聚集为可重复使用的视图。

Add a XIB to your project as described above. Add a few controls to it that you wish to aggregate as a re-usable view.

现在 - 在你的其他视图/视图控制器之一拖出一个UIView要求,你的总量控制将要使用的空间。

Now - in one of your other Views/view controllers drag out a UIView to claim the space where your aggregate control will be used.

创建一个IBOutlet UIView的* _customView并在您看来,绑定了出口到刚拖出来的UIView的。这仅仅是一个容器在这一点上,你有一个伊娃/ IBOutlet,所以你可以添加的东西出来。

Create an IBOutlet UIView *_customView and in your view, bind that outlet to that UIview you just dragged out. This is just a container at this point and you have an iVar/IBOutlet so you can add things to it.

到现在为止,我们已经建立一个UIView布局,将包含我们的总量控制。

Up to now, we've create a UIView layout which will contain our aggregate control.

使用的UINib类杜绝您的厦门国际银行用户控件。这里的code,我把viewDidLoad中:

Use the UINib class to stamp out your Xib 'usercontrol'. Here's the code I put in viewDidLoad:

UINib *nib = [UINib nibWithNibName:@"TestView" bundle:nil];
[_customView addSubview:[[nib instantiateWithOwner:self options:nil] objectAtIndex:0]];

不完全是刚拖出,但实现UINib缓存布局,因此您可以快速杜绝新的实例,它无论你想添加到您的形式,同时利用IB的布局控制UIView的。

Not exactly just dragging out but realise the UINib caches the layouts so you can quickly stamp out new instances and add it to your form wherever you want while leveraging the layout control of IB with the UIview.

这篇关于.net用户控件X $ C $等价的C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆