Moving objects in Xcode without adding to underlying object - ios

I'm trying to move object in Xcode's storyboard editor, but I can't find the key combination to use so that the object does not het appended to underlaying view.
My case:
TOP
Button
SubView - UIView
Image
Label
BOTTOM
I'm trying to move the button, but Xcode automatically adds it to SubView, so result is like:
TOP
SubView - UIView
Image
Label
Button
BOTTOM
I'm animating the SubView on Button tap, so Button can't be in the SubView.
Is that possible without manually selecting the object in object tree and editing position manually?

While you're dragging your button down to the bottom of the object list, once it's in the vertical location you want, drag it left. Like, further left than you think you should have to, until the correct parent view is highlighted.

Related

Is there a way to exit the current view group while using pan gesture in ios?

So I have a horizontal scroll view at the bottom of my screen which contains child views. I would like to drag a view from the bottom and snap it to a defined position on the top. But while dragging the view, it only moves about inside the scroll view. Is there any way to exit the scrollview and get the view outside it?
Layout of the app (I want to take the items from the bottom and snap them to the positions on top):
When you try moving views coordinates with drag, it will only move on its superview, i.e. your bottom scroll view.
If you wanted to drag your button outside of your scroll view then you need to have a trick here.
When user started dragging the button, hide it.
Add the same layout button on main screen on exact position.
Move the newly added button on main screen where ever you want.
Once you drop it, remove the old scroll view button.
It will look like you dragged the same button on main screen but under the hood it was a different logic.

Swift, iOS - have button move up when clicked to display text field? Then move back?

I know how to accomplish this in something like sprite kit but with just a normal ViewController I'm a little lost - right now I have my button and my UITextfield set up on my xib file. Right now, when the button is clicked my textfield goes from hidden to not, which is great.
Problem is I need to have my button slide up (as in animate up) to "reveal" the text field when clicked. As in the textfield would be underneath the button. When another button is clicked, I want the button to slide back down to its original position. I don't know how to implement these animations.
Here is an image of what I need:
So the blue button would trigger the move up when clicked. Then if another button is pressed the blue button moves back to original position over textfield.
How can I accomplish this?
Here's an option you can try if you aren't displaying these in a UITableView:
Setup your .xib with all of the possible views in an 'expanded' state. Give your views that will be revealed a height constraint (in addition to the others needed to layout the view properly), and then create an outlet for those height constraints in your view controller. Additionally, store a reference to what you want the expanded height of the view to be in your view controller.
In viewDidLoad of your view controller you will set those height constraints' constant values to 0. This will cause these views to effectively disappear, and your other views should fill in the gaps they leave behind based on their constraints.
When one of your buttons is pressed, you'll update which views should be visible by setting their height constraint to 0 if you want them hidden, or to the value you saved earlier if you want them shown. After the height has been updated, call
UIView.animateWithDuration(howLongTheAnimationLasts) {
self.view.layoutIfNeeded()
}
which should animate the change in height values.
Alternatively, you could try putting your options in a UITableView and altering their height using tableView:heightForRowAtIndexPath: and reloading the cells when their heights should change.

iOS: How can I remove reference to sub-views?

I'm creating an app that has hundreds of view controllers in interface-builder. Each of these view controllers has a button with a code number. When the button is pressed I want the button to expand and show a few lines of text describing the code number. The problem is that the button is placed within a subview that acts as a frame for the button. Therefore, the expanded button size is going to be constrained to that subview and the text will be cutoff. Is there a way for me to programmatically remove the reference to the sub-view? I can do this in interface-builder, but like I said there are hundreds of these view controllers.
Instead I removing it you could expand the subView's and the UIButton's width. That would allow the button to expand as you'd like it to and you would not have to remove the subViews.

UITextField inside a UIView thats animated on touch dismisses the view and shows the keyboard

I have a structure for my UIView object and have form elements within it. I run the application and the program is in such a way that when i click a button inside the UIView, it moves the current frame upwards. But thats not the problem.
My phonenumberfield is of type UITextField which is inside a UIView and that UIView is a part of the parent View. I have one button called submit and a segment control on the Parent UIView. But when i touch the phonenumberfield or any textfield type on the parent view, the parent view gets dismissed and keyboard shows up. Its weird I cant understand what the problem is because can't debug this. :(
I had a problem with the constraints for Auto Layout I had set for my scrollview and managed to fix the constraint and my view started scroll. To animate the view, I set a constant height from the top of the parent view and animated the view by changing the constant which did not affect the keyboard anymore.

How to make UIButton overhang over parent view and still make it all selectable?

I have a UIButton which is a child of a custom UIView. I've placed the button so its center is directly on top of the top right pixel of its parent view. Currently only 25% of the button (the area of the button which is within the the parent's view bound) is selectable. Is there a way of making the rest of the 75% selectable?
Here's a link to a diagram of the problem
Thanks!
Since your button is a subview of the bigger parent view, touch events are not registered outside the bounds of the parent view.
I recommend that you add the button as a subview to the same view that the bigger view is in. You will have to convert the frame location to keep it positioned the same way.
UPDATE
You can convert coordinates automatically using the UIView convertRect:toView: method.

Resources