Group views in Interface Builder - iphone

Is there any way to move a group of views within another without grouping all in the center?
Edit:
Here some images with the process.
1.- I have a view with separate subviews (labels, buttons, images...)
2.- I create a new view (that will contain all the subviews)
3.- Select all the subviews and put them in the new super view.
4.- When the subviews are in the new "super"view, all of them are centered and I need to relocate all.

I found a very nifty solution that you are not gonna believe .. !
I had a group of like 30 labels and buttons positioned pixel by pixel, so I HAD to, no matter what, move them while preserving their relative locations to each other.. Here is what I did:
Select all the views (labels, button, ... etc)
Editor -> Embed In -> View. (Now, they are in a view)
Move that view wherever you like. (Heck, you can even cut and paste it to a new NIB!)
Selected the view, Editor -> Unembed ! :D
I haven't read this anywhere, I came up with it yesterday .. Am 100% sure people somewhere have found this way before me, though.
EDIT:
It seems Xcode 4.5 renders this answer obsolete. Copy/Pasting a bunch of views now retains their relative locations to each other. Don't bother with this if you grew a habit on using it!
Actually, I think this answer is still viable!

You can make one view except xib's main view add that view contain all imageview,label in this view like below image. Assign IBoutlet to the the ViewInvoiceNumber and when set frame add subviews will move according that view like group.. But you have to enter all label,button,image view as subview of that view..
Hope, this will help you...

Related

Moving subviews from one view to another view without changing any position information in storyboard?

I have an iOS app in which i have created some view-controller in storyboard, the view-controller's view has some subviews. Now I want to add some scrollview in that view and want to move all those subviews in that scrollview.But the problem is when i drag those views to scrollview, interface builder is centering those subview, all the position information is lost.
I don't want to let interface builder to do that. Isn't there any proper way to solve this problem? I have already searched about this problem and found these two solutions but none is useful in my case.
Adding a subview to the current view without messing up positioning of objects in the view
I am unable to use this solution because, this is adding a view into another view while i want to add scrollview.
XCode - Is there a way to drag a component from one view to another without losing its frame?
Also this solution is not helpful for me because, storyboard file is messed up and corrupted when i did this.
Yes there is an easy way to do this:
Step 1: Select your views
Step 2: Go Editor > Embed In > Scroll View
Done!
PS. This is a very handy way to group views in fact. You can embed any views into a 'container' view, move it wherever you like (even cross-scene) retaining relative position information and then you could keep it as a group or unembed them.
If anyone comes across this question trying to find a way to do this programmatically (as I did), here's what I ended up using:
for (UIView *view in [_viewAdd subviews]) {
[_viewMain addSubview:view];
}
Note: addSubview removes the view from it's previous superview so there's no need to code for the removal

Add UIViewController over another but buttons on parent still clickable

.m file.
- (IBAction)switchViewThinking:(id)sendr {
[self.view addSubview:pick.view];
pick.view.alpha=1.0;
[pick animate];
}
The view pops up fine. Only the buttons on the parent view are still clickable behind the subview that overlays it. Also pick is a UIViewController. The parent view has 3 buttons each open a differnt subview. On the subviews buttons are not clickable through UITables or Scrolltext. Linkage is correct and views remove and activate when needed to. Is there a setting I'm missing that would cause this? Whats the best solution to overcome this.
Thanks
You'll have to either re-create the buttons on the top layer (maybe as transparent clickable views) or make the top layer smaller so that it doesn't obstruct the buttons below it. Instead of one large view on top, you could create many smaller views that look like one view,but that still allow the buttons beneath to be visible and clickable.
In any case, I'd advise thinking whether you really want this behavior. Seems a little like it would not be intuitive for the end user.

Scrolling through UIScrollView in Interface Builder for Xcode 4

This seems to me as though it would be a common problem, but I can't seem to find the answer anywhere. This question seems to address the issue, but I can't seem to get the solution to work and I'm not sure it's referring to Xcode 4.
When using Interface Builder in Xcode 4 and working with a UIScrollView, is there a way to scroll the view down in Interface Builder itself to view/add/edit controls that are out of the viewable section of the screen? I've managed to push a couple controls down using the arrow keys, but now I can't see them and therefore can't manipulate them in Interface Builder. Scrolling the view in IB would be first prize, but if there's a way to even select the controls using a drop-down menu or whatever so I can push them back up with the arrow keys, that would at least be something. Thanks.
Set the ViewController's Simulated Size to Freeform and set a very large height. E.g: 1000 and voilĂ ! You can now scroll to see all the stuff and add even more! :)
P.S: Remember to set set Fixed when you are finish to avoid problems!
Just a workaround which helps in Xcode4:
Expand the Objects Panel which resides on the left of the Interface Builder view (there is the tiny arrow at the bottom of the panel).
Drag your UIScrollView from the view hierachy and place it on the top level.
Now you can resize it to access more content (scrolling to that content did not work for me).
When you are done adding child views to the scrollview, you need to resize it back to be smaller or the same size as the parent view.
After your changes you would need to put back the scroll view where it belongs in your hierachy
I typically do the following when I want to (have to) build a long scrolling screen:
Set the size of the View Controller to Freeform
Set the height of the top level View to something very large
Arrange all the controls that I want on the View
Select all the controls
Select Editor->Embed In->Scroll View
Set the size of the View Controller back to normal (typically Inferred)
Well, there are a few different things you can do. There is a list of items in your view you can open on the left of the workspace by clicking the button that looks like a little play button on the toolbar. Double clicking any item selects it so you can use the arrow keys.
The best option is to use the layout panel (typically on the right) and enter position values manualy. Sometimes I will use this to move my scrollview up to where I can see where I'm working then move it back.
I found a solution although you have to use a Table view controller. If you define the table as static, the scroll works in interface builder when the table is bigger than the windows size. Moreover, a standard view can be added to the top and bottom of the table, these views are scrollable as well. The scroll is made once the controller is selected. I hope you find this trick useful.
I know this isn't exactly what you were looking for, but I always just drag the scroll view out of the view controller onto the "pasteboard" where you can resize it at will and see the whole thing.
Once I make my edits I simply resize it to fit it's allotted space in my view and place it back in the view controller.
set the root view to freeform and ~1000 pt height, go through the child views and set them to this height as well(including scroll view), in the viewdidload method set the height to the appropriate size.

Is it possible to put one UITableView over another UITableView in InterfaceBuilder?

I know I can use codes to add UITableView one by one.
[self.view addSubview:tableview1];//
[self.view addSubview:tableview2];//
I hope to do the same thing in InterfaceBuilder, when I drag one UITableView onto another one, the new one always pushes the old one to the bottom, rather than just stays over the old one of UITableView.
Welcome any comment
Thanks
If you have a parent view that will contain your tableviews then you shouldn't have any problem. If you're trying to place them directly in a window then I could see a problem. If things aren't lining up the way you want you can always change their position via the Size Inspector or by nudging them with the arrow keys (shift-arrow key moves in 10 pixel increments).
Why anyone would want a tableview on top of another tableview escapes me.
Your parent view should be a subclass of uiviewcontroller and your xib should have the root view as a uiview and not uitableview.
I used two overlapping table views to show two different contents on the same view, which could be toggles using a segment switch. Apparently my client requirements were vague enough that I couldn't just filter out data like how the phone app displays all calls/missed calls list.

Moving and existing UI on a UIScrollView

I have some xibs with all sorts of text controls (UITextFields, UITextViews). Since the keyboard obscures some of these text controls when text input starts, I followed Apple's guideline for managing content located under the keyboard.
In short, the solution involves moving all interface elements on a UIScrollView. Doing it from Interface Builder I simply add a UIScrollView on the view, make it the size of the view, send it to back and link it's referencing outlet to the file's owner view property.
In IB this all looks fine, and the UI elements appear above the UIScrollView. However when I run the program, the UI elements are nowhere to be found. Their IBOutlets however seem to get initialized so it looks like they are actually constructed. I've tried to set the UIScrollView alpha to 0 to see if they are placed behind it but I still can't find them. New items that are added to the UIScrollView however, seem to work fine.
This leaves me with the not so great option of rebuilding all my xibs where I need to do this change. It kind of looks like an Interface Builder bug to me. What do you guys think?
Well I've found a solution. It goes like this:
Drag a UISCrollView in IB's main window (where we have the File's Owner and First Responder objects).
Rescale it to the size of the initial view
Drag and drop everything from the original view to the scroll view.
Link the scroll view's referencing outlet to the file's owner view property.
Delete the old view from IB's main window.
#MihaiD
use tableview.contentOffset=CGPointMake(x,y);
I don't know if you really need a UIScrollView. See this question on SO it slides the parent view up.