Ok, I have a navigation Controller that manages a drilldown tableview, when it reaches to the end it show a list of products, when you choose a product it will show a detail view (UiViewController).
What I want to know is how to "Enable" scrolling up and down in that detail view so i can show full information about the product to the user.
Thanks
Got the answer. If you are using Storyboards (like myself) you have to go to the attributes inspector of the UiViewController and change the size parameter to freeform, then select the UIView of the UIViewController and in the size inspector choose whatever width or height you want and finally grab the Scroll View from the object library and insert it.
You need to add an UIScrollView to the view controller's view, and set its contentSize.
Related
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 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).
!I have a UITableviewController with a navigation bar as header. there are 4 sections in the table, Number of rows in the table are more than that can be fit in the iphone screen. while scrolling whole view is getting scrolled!!. I want the header to be stationary and only table to be moved.
Also the last section is appearing twice! like this.
Table view controller snapshot
please help
Thanks in advance
First don't use Navigation bar as the header of TableView. You should use a navigation controller and push this viewcontroller which contains tableview. This will allow you to get rid of first problem i.e. to keep the bar steady and not scroll with the tableview.
Second problem looks really weird, it seems to be that you have laid out two UITableView in your nib. Check again and remove one.
You have two options:
1) add a base UIView on which your header view and your table view are siblings.
2) set the header view as the table view's viewForHeader of the first section
You have only one option:
1)create a UIView lets say headerView and add control or whatever you
want to have and put that custom UIView on top of your UITableView
2)Do not implement viewForHeaderInsection
3)Change the y position of your UITableView to place your tableView
below your headerView
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 a UITableViewController subclass and it appears in a navigation stack however I want to add a view (uisegmentedcontrol) to above the tableview like in the AppStore when you go into categories and drill down un a list of apps there is a segmented control with paid free and grossing. If you scroll the tableview it stays attached to the navbar. Unlike adding a view to the table header which means it scrolls with the content which is not what I want.
Your best option is to create a UIViewController, then add a UISegmentedControl then a UITableView.