How do you set autosizing to flex in Interface Builder? - iphone

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

Related

ViewController's content is pushed down by navigation controller

I am setting up a login page in my app and decided to add a navigation bar to display an image/logo. However, after I added this navigation bar and ran my code in the simulator the content of my view is being pushed down. I have attached pictures to show the difference between the interface builder and the simulator. All of my constraints are related to the super view and my view encompasses the whole screen.
interface builder screenshot
simulator screenshot
follow the steps :-
add a new view inside the main view
insert all elements in that 2nd view
give the constrain to 2nd view (if possible then give static height and width)
give constrain to all elements inside of 2nd view
must give 2nd view center x,y constrains
i hope it will work for you ...!
For anyone who comes back here later:
All of the above answers work in their cases, however the issue for me was that I had "under opaque bars" in my storyboard unchecked which caused the view to display lower than it should.

How to edit a View hidden behind other Views in Xcode Storyboard?

Is there an easy way in Xcode to edit a view that is hidden behind other views within the Storyboard? I know I can hide the views in front of it and move the view to the front temporarily, but this is difficult to keep doing over and over again. Is there a way to isolate the view somehow in Storyboard so I can edit it on its own?
Select your view controller in storyboard and Open File Inspector
Select Use Auto Layout and Use Trait Variations
Now select the view you want to hide in your storyboard. Open Attributes inspector. Check/uncheck the installed option to show/hide the selected view. You can hide multiple views by changing this property after selecting all the views.
Don't forget to check this option for all the views while running the app. Else it will crash

Display items inside ScrollView on Storyboard

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.

iPhone make toolbar visible in UITableView

I have a UITableView has a subview of a UIView and I've added a toolbar on top of the UITableView so it should look like this:
However when I actually run it, it looks like this:
So for some reason the UIToolBar isn't showing up. I really don't know why, is anybody able to figure this one out? Thanks in advance.
EDIT: I've changed the simulated metrics like suggested and it still does not show up:
EDIT2: Here is a list of objects as requested by Raixer.
Alright. I have a similar setup in my app so I will show you what I did.
I setup a tab bar controller with navigation controllers in each tab (this gives me the navigation bar automatically that is why I use it). If you notice the View on the first tab is being loaded from another nib (that is what I am assuming you are doing). I did this by changing the view's class to my own view controller and then setting the name of the NIB file to load in the Inspector like this:
(source: minus.com)
Then in my other nib file I only have this:
I hope this helps.
That's because you configured your nib file without counting with the height of the Tab bar.
The toolbar's height is 49 pixels. So when the view appears all your elements are moved 49 pixels up.
You should got to IB, open your View, go to Attributes Inspector, and in simulated metrics select Tab bar for Bottom Bar.
I doubt you will succeed with this approch. UITableViewController is very picky about adding subviews to its UITableView. However, you can have your UITableView handled by a standard UIViewController (just let IB point to a custom class inheritng from UIViewController). Add the table view to the controller's view as a subview and add the toolbar to the outer view.
Then you should be able to add subviews. UITableViewController gives you some convinience and functionality. If you can live without, UIViewController is no disadvantage. If you can't, you'll have to implement it yourself.
Another alternative to get the toolbar: put your table into a UINavigationController. That one comes with a toolbar (on top).

In XCode 4, how do you change the number of tabs in a UiTabBarViewController?

I've been looking at this new interface for a while now and I can't figure out how to add or remove tabs from the tab bar.
Any help would be appreciated.
There are two possibilities:
1 - Open your xib-file inside Xcode. Show the right sidebar (Navigator | Utility). At the bottom of this bar should be all Interface Builder objects (i.e. UITabBarItem, UILabel, ...). Now drag a UITabBarItem to your View.
If you don't see these objects: At the bottom is a small cube. press it and you'll see it.
2 - Right-click on your file and open in external editor. This opens Interface Builder. If it won't work you can open your file directly with the Interface Builder.
You ask this question in the Apple Developer Forums where you can talk about confidential information (read: NDA software). Xcode4 is not yet available for public consumption, therefore it's still under NDA.
I also work around on find out how to set the tabitem in Xcode4, I found you just drag the controller to the tabitems, the select the uiview of this tab item and set it's class. Xcode on longer support set tab item at the inspect panel.
Assuming that your Tab Bar was created in XCode (which it should be if you created a Tab Bar project) click on your Main Window.xib to view it.
Click the disclosure indicator to see the hierarchy of objects (if it isn't that way already).
It should look something like this:
The number of view controllers that you have underneath it is the number of tabs you have.
In this case the view controller is a Navigation Controller, and the View Controllers are children of it.
If u r using Story board .........
Just do this ...
and i am telling for Xcode 4.3
just add view controller from the libirary you can add as much as you like..
then link those views with your main view controller...
as you will link with it ....
it will automatically pop up relationship with main controller and thus a tap will be added automatically in your main controller...
you can visit this link ....
"http://www.youtube.com/watch?v=qvvJzkJcsew"