I am maintaining some code, part of it is a very cluttered xib file with two table views on top of each other (only 1 visible at any time when running) - I need to connect data sources and delegates from each of the tables, but because they're on top of each other, when I drag across, it always picks up the top one. Moving stuff around is not really an option, because it's very cluttered and cramped.
Any ideas on working efficiently with cluttered and complicated xib layouts?
If you're working with Xcode 3, look to the small window that shows the main objects, usually File's Owner, First Responder and View. There's a button on the top left of the window that lets you choose viewing by icons, list, or hierarchical. If you choose either list or hierarchical view, you can clearly see all your views and subviews in their hierarchical structure. You can right-click on any of them to make connections. When you have many views, one on top of another, it's usually much easier to work with them here.
I haven't moved to Xcode 4 yet, but there must be a similar option to view the hierarchical structure of views and subviews. I hope this helps some.
Related
I am trying to create an interface similar to the app Instapaper. The works just like a navigation bar except its on the left hand side.
I'm having an issue creating this interface. Any ideas on how to do this type of interface. I was thinking of a window with a view controller split up with two different views.
Any ideas, suggestions, or even a tutorial?
Mine (in Instapaper) is just one big view controller with a sidebar view that toggles the contents of the larger view manually. It's not too bad in my case, since it can only have two states -- grid or browser -- that simply switch which data is shown in the grid/browser.
If you can require iOS 5 as the minimum, you can use some of the new child-view-controller mechanics, but I couldn't yet.
You may want to start with and try this library out
In IB I have quite a few views that are shown. Many of them are hidden when the app loads, but are shown later when buttons are pressed. This is all fine, but when building this layout in IB it is extremely difficult to layout anything because there are so many overlapping views, some of which are partially transparent (ones that are set to hidden) and other are completely overlapping and covering others. This makes layout very hard.
What is the best method when laying out lots of views like this? Is there another way to break things up? Or better yet, can I hide a a view completely (like in photoshop) so that I can edit the ones underneath, then turn that layer back on?
Another option when trying to select a view that is obscured by another is the shortcut:
'ctrl' + 'shift' and click
It displays a list of all the views under the cursor.
I'm not aware of any way to hide objects in the canvas, but a useful trick for complex layouts is to double-click an item in the document tree to the left - this selects the item and puts focus on the canvas, you can the use the cursor keys to nudge it about.
This doesnt solve the problem of not being able to see things because there are, for example, five or six labels occupying the same space, but if that is the situation it may be a better idea to have a single label and change its contents in code.
I ran into this issue for an app I'm building that has an arial-view image of a park with clickable hotspots. When a hotspot is clicked a popup UIview is displayed with information about that spot in the park. I use the same VC/XIB for three parks. This makes the XIB really busy and hard to work with (i.e the same issue that you have) The detail UIViews make it hard to work with the views underneath. My workaround was to pick each detailed UIView that was hiding the part of the XIB I wanted to work on, and add 1000 to the UIView origin.x in the size inspector. This moved those UIViews enough out of the way for me to do what I needed to with the XIB. Then when I was done, I moved them back by x 1000. (I just needed to move them out horizontally to do what I needed to)
I know its clunky but given that XCode does not have a convenient way to hide portions of an XIB - it was the quickest approach I could think of!
One approach to handling overlapping items in IB is:
Ensure the groups of items that you want to hide are grouped into Views.
Give these Views names: e.g. ViewOptionA, ViewOptionB and ViewOptionC.
Can do this by clicking on name of view in the tree while it is selected and then typing new name.
When you want to hide one of those groups of items:
a) Select the View by either:
i) Clicking on it in the tree at the left or
ii) Ctrl-Shift Clicking in the layout editor and then select the view from the list.
b) In the Attributes Inspector set Alpha to 0.
When you want to unhide one of those groups of items:
As for 2) but set Alpha back to 1
[You do need to remember to unhide all views before you publish!
If you are forgetful like me then perhaps you could subclass UIView and set Alpha to 1. I haven't tried this subclassing idea yet.]
In my iPad application there are many buttons (around 50), and I want to make a group box which contain buttons arranged by category.
I am looking for something like a C# or .NET GroupBox/Panel.
There is no Group Box / Panel Box in iPhone.
You need to manage by your self.
Use the UITableView to put all the button in on category.
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableView_Class/Reference/Reference.html
It may be worthwhile to look into UIPopoverController views. These are the little popup views that appear when you click stuff. YOu could easily break your menu system into smaller parts with these.
You may draw a group panel by making two views. make a view of frame say 20,20,280,199 and then another one with frame 21,21,278,197. now put the 2nd view on the last one and change the color of last to some dark than later one. enjoy :)
remember that the should be in same hierarchy. that no one should be parent or child of any of these.
I am fairly new to programming and I am working with Objective C. I am trying to program an app where you have a UITableView, than you click on cell, which will bring you to another UITableView with more options. I have only encountered problems, however, in populating this second UITableView. Any suggestions for how to do this? Do i need to create new classes for each new table?
You could also look into a UINavigationBar if you are going to navigate through tables and want to go back and forth between them (once you get it connected to everything correctly, UINaviagationBars can be great, because you don't have to worry about what level you are at in your tables, it takes care of it for you! but like i said, after you hook it up right, which is a pain in the butt)
Your question's a bit vague, but it sounds like you need two UITableViewControllers:
ParentUITableViewController: This houses the top level table view that, when you tap on an element, moves you to the second
ChildUITableViewController: Houses the child table view that populates itself based on what was tapped on the first
The Apple examples are excellent for learning this sort of architecture, this one may be exactly what you're after: DrillDownExample
I have a table that contains 4 varying types of data and depending on the type of data that is selected by the user, a specific edit view is shown. One of these views has one edit field, a second one has 2 edit fields, a third one uses a picker, and so on. What's the best way to handle these varying views without an explosion of classes and without too 'switch'ing to figure out which data I'm working with?
One way I can think of is to have 4 different view controllers with respective views and then launch each one when the specific item is selected in the table but is there another elegant way to do this?
You can either go with the four different view controllers, or have one view controller that accepts an argument in the initialization for which content to create. The second approach seems to work better when the views are very similar (different numbers of the same controls, etc.)
For your case, some views have pickers, some have text fields... It seems that it might be best just to create a different view controller for each. With this you get added flexibility down the road, even though there is slightly more code to maintain.