Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine several iOS controls in one entity (control)?

I want to implement custom search and have one trouble. I need to combine UIButton, SearchBar in one control in order I can refer it by pointer.Then i will dynamically add more UIbuttons to that combined control.And the most important I want to manipulate this combined control as one program entity. For instance,CombinedControl* control; So what the common way to implement this? Or may be I can emulate this?

Thanks in advance!

like image 884
MainstreamDeveloper00 Avatar asked Nov 13 '22 19:11

MainstreamDeveloper00


1 Answers

If you're looking to combine multiple controls into a single unit, the simplest thing to do is just to add them as subviews of a single UIView. You can do this either in Interface Builder (by creating a blank UIView and dropping the other controls on it) or in code (using addSubview:). Then you just have a variable that points to the UIView that you added everything to.

If you want to add behavior to the "combined control", then you should create a subclass of UIView (as H2CO3 suggested above) and add the controls to that view subclass.

like image 107
Joe Trellick Avatar answered Dec 10 '22 21:12

Joe Trellick