UIView inside UIView, drag to show the content - ios

I have a view and inside it i have another view, the lower view should show the top area of that view, its hard to describe so i will let the following images talks about itself :)
1- This is the first case, when the app launches you will see two UIView's, one is added below the other "in my case lower view is the one below".
2- lets suppose that i will put the following picture as an image view in the upper view:
3- When i put the image from point 2 inside the upper view it should look like this:
4- and i when i drag the upper view it should expand over the lower view and start showing the rest of the UIImageView as follows:
5- and if i drag in to the upper side of the screen it should look as the following:
So, any idea how to achieve that?

Not clear about your question. However, try some dragging and dropping uiview libraries like Drop and drag UIView

Related

How to show dynamic label on image view programmatically in Swift 2

I have a view controller which contains 5 image views which I connected them to a class which controls the functions and actions for them! but I need to show dynamic UI Label on them, in the right bottom corner of each one, but don't know how to do that.
This is my current view controller:
But I want to make it look like this:
UPDATE :
My problem in Xcode if I try to add the label view in the story board it adds the label after image view not on it:
I managed to recreate your problem - and I found a solution!
If you add an empty UIView first, you can add the image and the label to that view.
You end up with a stack of UIView, each one containing an image and a label, and you can position the label anywhere you want within the UIView

Best way to have "float over" controls for a UICollectionViewController?

I have a UICollectionViewController setup. It shows something kind of like a gantt chart, with selectable bars, scrolling, etc. I want to have a "trash/delete" button that always floats in the bottom right of the screen, regardless of scroll. It will delete the current selection (if there's one) in the UICollectionView.
I see two basic approaches:
Use the Supplementary Views facility of my UICollectionView. What I dread about this, is that I'll have to muck with its layout in my layout (I'm using my own subclass of UICollectionViewLayout) to keep it positioned in the bottom right corner, regardless of scroll.
Just add a UIButton to the canvas and set it up there. Maybe this isn't even a real approach, because this is what I wanted to do. While my button may manipulate items found in the UICollectionView, it's not really a real member of the collection view. But I found when I tried to drag a UIButton onto my Controller in the storyboard, it wouldn't stick. It doesn't seem to want to add it. Do I have to change to use a UISingleViewController, and then have a top level view that I can add both my button and collection view into? And then repeat all of the handy delegate/property setup that I get for free from UICollectionViewController?
You:
drag a button on to the view
in storyboard/xib.
Then, in the hierarchy column on the left, ensure it is at the bottom. That means it will be in front of everything else.
So, if necessary move it so it is in front of (ie, below in hierarchy) the collection view.
Note that there is absolutely no problem, at all, with putting one control "in front of" the other (i.e., so that it "blocks" you from seeing all or part of the other one).
If you had a problem doing this, you've made a trivial mistake. For example you may have dragged the new button "into" the collection view, rather than as a "sibling of" the collection view. Hope it helps.

Placing a control over a mapview iOS 7 using storyboards

I'm trying to place a button over a mapview. In storyboard I have it as the last control in the view hierarchy, the map view still covers it up. I've tried adding this line in my viewDidLoad method to bring my button view to the front but it doesnt seem to work either
[self.view bringSubviewToFront:self.flagButton];
anyone have any idea why this wouldnt be working? the map view covers most of the screen, and I want to place a few buttons on top of the map, but so far can't get them to show up, they are under it every time.
I was able to do this by making my view as subview of map view.
first,
self.view = self.gmsMapView;
then,
[self.gmsMapView addSubview:_myBtnView];
I know this is an old post, but I'm answering for the sake of someone facing the same problem.
I was having the same issue, then I found a solution, and is as follows:
First, open your project and go to your StoryBoard then click on "Show Document Outline" switch that is on bottom left very small switch. After that select your "Scene" that you are having problems with then click "View". Find your MKMapView object and drag it up until you reach the first row. This will make your MKMapView object (or any other) "the first in a layer" so to speak.
I hope someone will find this helpful.
E
I was using storyboards and was not seeing the button. I had to set the MKMapView to hidden until the button was displayed and in position. Then I set the MKMapView to visible.
Here are the steps I had to take in the interface builder to get my button to show
Create a UIViewController which contains a view
Add an MKMapView and set constraints
Add UIButton in the same view as the MKMapView, set the image and text, whatever is applicable. If MKMapView disappear when you try to resize or move the button, the map view has just set its width and height to zero. Enter new values in the Size Inspector for the map view and it will resize back. Or you can move the button elsewhere off the MKMapView and then move the button back to where you want it.
The important part is to set constraints for the UIButton. I also had to set the MKMapView hidden until I got the size and placement right and then set it back to visible.
Here's how it looks in the simulator
You can't add a subview to an MKMapView via the storyboard. Add it as a sibling view instead.
Edit: Your map view should also be a subview of the root view (i.e. self.view) for this to work.
I was having similar issues and I did the following:
Made sure both the map view and the button are at the same level in the view hierarchy, I accomplished this by creating a View that both the map view and button were children of.
Made sure the button is dragged below the map view in the left gutter of the storyboard (so it is actually rendered on top).
Made sure there were valid constraints for the button.
The only thing new that hasn't already been mentioned was double-checking the constraints, and that appeared to resolve it for me. Hope that helps.

ViewController gets misplaced, when a view size is adjusted

I'm quite new to the Xcode programming. I've added some view controller, labels, buttons and image view to my program, but, when I try to adjust, for example, the size of a label, the view controller that that label is in, gets displaced. I mean, when I try to drag the side of the label to change its size, the view controller moves down, making my label get displaced in the view controller. It is a very weird situation, here you have the screenshot of my project, the view controller misplaced is the one that says "Perfil" on the navigation bar. Every time I try to change one of those light blue views size, the entire view controller changes place. The more I try to change the side the more it will go down.
Sorry for my English, not my native language.
I think the bigger issue is that you are using Table View Cells that are not part of a table view.
Table ViewCells are supposed to be a part of a UITableView and not just stuck in a view.
Using UITableViewCells in this way is what is causing the strange behavior.
If you are trying to make a table, put a UITableView in your view, and then you can customize the table view cells in there.
It you aren't trying to make a table, just use UIView's instead of those UITableViewCells.
I have two ideas that may fix the problem:
First, if you're trying to drag and drop the label but the view controller moves instead, then you might just be grabbing the view controller's background by mistake. When this happened to me, it was because the order of my components in the xib file was wrong. Things are ordered from back to front, and when you click and drag something, you'll just be clicking and dragging whatever's on top. You can try and get past this by clicking the UI element on the left to be sure you select it, then dragging the handles.
It looks like you have things in a reasonable order, so that may not be the culprit at all.
Second, if that doesn't work, select the element you want to edit on the left, then open up the utilities pane on the right. Click the Attributes icon (should be fourth from the left) and look towards the bottom. You should see something like this:
Just manually edit the position and size of your labels there. You should see the change immediately reflected in the display.
Hope this helps!
Setting no autoresize behavior in Interface Builder solves the issue.

Positioning items in overlapping UIViews in xib file

Let's say that I have a xib with a stack of UIViews on top of each other:
The bottom UIView(A) with a UIButton on it and when the button is pressed,
this layer is hidden and the next one is shown and put on top.
The next UIView(B) contains a clock counting down from 5 to 0
and when 0 is reached this UIView is hidden and the one described above is
moved to front and shown instead.
So just to make it more clear:
the composition of the xib:
A B
--Z direction-->
update: screenshot attached at the bottom of page.
So to my problem:
When (re)positioning the button or the clock using mouse in Xcode they tend to stick to the wrong
UIView. The more the Objects and "stacked" UIViews the greater the problem.
The Question:
Is there any way to, as with the layer "eye" in photoshop, isolate the UIViews and work on them one by one?
Observe!
I am aware that there are o there ways of achieving this swapping between view BUT this is not the issue. The real problem here is to actually position the button and the clock in the Xcode wysiwyg editor with the least hassle.
Observe!
-------- Added for clarification --------
Screenshot
I would like to isolate the views visually so when working on one of them, all the others are hidden and not open for interaction.
You can drag the second view (B) out of the main view hierarchy and place it below it (on the same level of the main view). That way you'll be able to edit each view separately.
Then you connect that view (B) to an outlet in your viewcontoller inorder to be able to add it to your main view during runtime...just set the frame and add it as a sub view.

Resources