I can drag & drop a ui element from the "objects-selection" and add it to my current scene (marked red in the picture) but how can I edit it? Xcode doesn't show it in the editor, nor does double clicking the element make it visible.
Depending on what you want to do with it.... Perhaps you could make it a subview of the current view in order to configure it and then remove it from its superview in code if you don't want it to appear.
Based on the hierarchy picture you provided, you are aware that the view you added is not part of the view controller's view hierarchy, correct? You would need to set the view controller's view property to this view in order to see it. If your intention was to add this as a subview of the current view, you should drag the view from the object repository directly onto the view. Alternatively, you can drag it from the View Controller Scene on the left and associate it as a sub view that way.
Also, note that when you pull the view onto the canvas, it's white. It may have been there and you just didn't see it if you had originally made it a subview of the current view.
I suppose the right way would be to add the extra view to the view controller's view, and have it hidden. Yes, it is going to be a pain to configure views this way. On the other hand this way those views do got the proper memory treatment and can get unloaded under memory pressure.
Related
Here is a photo, I need to make this when you click on the right button it is moving you forward and backward for the left one.
Here is the result I want:
The buttons moves you to a different views
I think you can create a view and add label for title also page controller too after that add collection view under view and enable pagination. Use custom nib file for views (screens).
My problem is when i want to display multiple items inside a scrollview on Storyboard, i can't scroll to add more items because of the screen size of the View Controller. How can i get around this ?
Xcode version : 4.6
Autolayout : enabled
Here is what i want to do :
EDIT : I found a workaround to this problem. Just add items with minimal height and then resize it in code.
Try to beloved steps
after add button resize of view(height=568) and Viewcontroller > Simulated Metrics > Size > inferred
There is a way. Might seem difficult but its actually quite easy. It's a hybrid solution, with storyboard and nib file. You have to build a view inside a nib file instead of a storyboard.
1) Create your view controller named, let's say, "MyViewController".
2) Create a nib file, named "MyViewController" (name of a viewcontroller and nib file must match for this trick to work).
3) Go to that nib file, you created, drag a scroll view from object library.
4) Look at the side menu, and search for "File's Owner" icon (empty
cube), Under identity inspector Change the file's owner to the view
controller you created, "MyViewController".
5) Right click on the file owner and a menu will pop up, control drag, from the view connection to the scroll view you dragged from object library.
6) Click on the scroll view you just dragged, and go to the attributes inspector.
Under "Simulated Metrics" change "Size" from "Retina 4 Full Screen",
or whatever it happens to be, to "Freedom".Now you can drag bottom
edge of the scroll view down, to make enough room for all the
subviews. Make sure you don't accidentally increase the width.
7) Go back to the storyboard.
8) If the view controller is not created, drag it from the objects library.
Change its class to "MyViewController".
9) Now this is where the trick is gonna happen.
Make sure you delete ALL views from that view controller, including
the background view. If you do that correctly you will be able to see
the grid background of the interface builder. This forces the
storyboard to look for a nib named the same as the view controller.
10) Run, and smile (Make sure that you add some subviews to the scroll
view, that are off the bounds of a single screen, so you must scroll
to see them, otherwise it wont set the contentSize correctly, and you
wont be able to scroll ) :)
make scrollview object and set in viewDidLoad .
self.scrollView.contentSize = CGSizeMake(320, 960);
Use what height you want like: 960
I don't think it is a very practical way to do it in IB. A better approach would be to do it in code.
I have an app where I have an imageview displayed within a UIView that the user has scaled and moved around, and I'd like to pass this exact same imageview to the next UIViewController that gets pushed onto the navigation stack. What is the best way to go about doing this? Do I have make some sort of deep copy?
controller.imageView = imageView;
There's not much special about this. The only thing you need to do is to add the view to your view hierarchy. Views can only have a single superview, so when you add it to a new view hierarchy, it is automatically removed from the old view hierarchy. The only tricky thing is when you pop back up the stack. Do you expect the view to still be available in the old view controller? (It won't be.)
In general, I'd tend to recommend passing the parameters rather than the actual view (i.e. the image and its transform). This gets rid of any issues going up or down the stack, but either way can work.
Give the view reference to the next controller, retaining it.
You could have some problem to deal with its bounds or frame, but if you just want the same, that should be ok.
In the new controller, get that passed view and add it as a subview of your main view. Don't forget at the end to remove it from its superview, and to release it before returning to the previous controller.
I've been looking everywhere but can't seem to find any examples/tutorials for my situation (not sure how to google it..)
So i have a window where a portion of it should be static (buttons and such) and there is a dynamic part (bottom leftish) that should change subviews.
So what i'm looking for is a way so that clicking the buttons in the static area will change the dynamic area to a view of my choice. I have no idea how to do this using the IB, but doing it programatically seems the only way. Any suggestions(I do not want to use a tab bar controller)?
Oh, and is there a benefit to making views and such programatically vs through the IB?
Thanks!
You can also achieve it programatically. Just create another viewcontroller class (as many as u want). In the loadView method of it create a UIView in the coordinates where u want to add the subview in the current view. Now create an instance of this viewcontroller class in the currentview controller and add it as a subview. You will get the subview at the desired location.If u want to change it dynamically create as many views and then add them to the array and change them whenever the button is clicked.
Hope this helps.
You should perform the switch in your view controller. The static buttons can have their actions hooked up to that controller (in IB), which can have an outlet (in IB) to the subviews and perform the swap.
As for when you should use IB, see this question.
You can do it from interface builder as well. You just need to take viewController from interface builder drag-n-drop to main window. assign IBAction to all buttons to add different viewController's view to main window just make their frame some smaller.
if u want to change or views by click on button then u chose segmentcontrol switch. and cod for each segment like as when click on segment 0 then open first sub view and when click on segment1 then open second sub view. And make by default unselected so that ur static view will appear initially lunching of view.
I have an iPhone project that I started as a Windows-based app and another View-based app. The Window app has a view which I added and I want to make the view fit within the window. In the View app the view is set to stretch.
Here is what it looks like when it is off.
(source: smallsharptools.com)
And here is when it is on.
http://www.smallsharptools.com/downloads/Stackoverflow/autosizing-on.png
I want to click in the middle of the Autosizing box but it does not do anything. What do I have to do in Interface Builder to make the View in a NIB to flex/stretch the view?
Usually when a view is locked down like that, it means that you have some simulated UI elements in place (like a fake nav bar, tab bar, or status bar). Select the top level view and go to the first tab of the inspector to see if any of those are turned on (you'd also see them on the view of course).
When they are all gone then you can change any of the resizing handles you like.
The view that is provided by default has this kind of limitation but you can overcome this by adding another view (you should delete the first view) to your xib and making this view the view of your file's owner. Besides this you would also have to change the height of this new view to 480 pxls.
Hope this helps.
Thanks,
Madhup