Displaying a list of views - objective-c

Here's a mockup:
A mockup http://img.skitch.com/20090228-mqdj17xijycc98spf181a8q6q7.jpg
I have been trying to find some sample code that showcases something like this -- a scroll view with a list of custom views. Haven't found anything. I've been trying to find some open source projects that does this (that isn't Adium with a million files and lines of code), but haven't found anything there either.
I've been told that I can use NSMatrix to achieve this. Again, haven't found any sample code.
Anyone got some suggestions? Or sample code ; )

You could also use NSTableView and create a custom subclass of NSCell to render the content.

If you can require Leopard, take a look at NSCollectionView. The API is a little weird but it's pretty powerful once you get the hang of it.

I've been told that I can use NSMatrix to achieve this.
You can't. NSMatrix uses cells, not views.
To answer your question: What James Williams said.

Related

Customized UITableView

I just want to confirm that which is the better way for handling the highly customized table view, is it by using the nib file or writing the code for each element ourself.
This question has been asked not only in regard to UITableViews. You can see some tests here:
http://cocoawithlove.com/2010/03/load-from-nib-or-construct-views-in.html
If the cells are very complex, it is easier to create a nib file for the cell, like here
http://adeem.me/blog/2009/05/30/iphone-sdk-tutorial-part-6-creating-custom-uitableviewcell-using-interface-builder-uitableview/
Memory wise, I can't tell you for sure.
But considering you are talking about a highly customized table view, using nibs is better because you can actually see the modifications. This makes it easier for you. Otherwise it would be a real pain to create a highly customized cell only by code, not to mention that it would make it nearly impossible to be edited by someone else than a programmer.
The best way will be to create a separate nib only for your cell layout as described here: UITableViewController with custom UITableViewCell

Add MGSplitViewController to simple project

I'm trying to use that MGSplitViewController (already mentioned here, but some one told me I have to ask a new question...), because some ideas will have one or more splitviews and Apple's reviews are not that easy to pass, so I thought I just use some time to test some existing frameworks, like the MGSplitViewController.
But I don't get it working for about 4 long and hard days(and some nights, too ;) ) - any help would really be really great!!!
My problem is the following:
I have just a simple start view with a segmented control. after the launch and some checks I would like to load the splitview in that simple view. I'm using the storyboard for the simple view and I added the xibs from the example (because I had no idea how to integrate them in the storyboard as well - seems to be the next topic, I'll take a look at...)
Sounds very easy, but with the commented header file and the demo project I'm absolutely not able to reproduce it for a non root controller loading...
I have packed the source code for better understanding, downloadable at
http://www.file-upload.net/download-3866273/mgsplittest.zip.html
.
If any one can help me with this, correcting the project, this would be really, really, really great!!!
Greetings,
matthew
I have solved the issue -
FORGET MGSplitViewController :)
Write it your own, really not difficulty:
need two views(navigation_left_sided, detailsview_right_sided) in the YOURSPLITVIEWController in the storyboard
all detailviews should be build with xibs, in storyboard I have not found a way doing this in a clean way (any tipps appreciated)
the leftsided view delegates calls/view loadings to the other
load your detailview controller and display
finished ;)
It is also a good training to work with delegates, observer and asynchronous dispatching. At the time I asked the question, I have not worked much with them - blame on me ;)
Advantage of writting your own:
- reusable
- fully customizable
- in portrait mode also visible, you can just change the sizes of both
- custom animations for changing the detailsview (move details from bottom to top or curl or anything)
- after this you have a lot of basic knowledge like delegates, etc... (it was in my case)
Or use the iOS6 feature for grids also very simple, but iOS6 based devices only...
That's it, very easy :)
Any questions? Just ask :D
But I have written the code for my company, so I cannot share, just answering questions and giving you the tipps from above ;)
Greetings,
matthias

The correct way to user custom UITableViewCells

I have seen a lot of different ways of implementing custom cells in a table view.
Like different file owners, get it from bundle and call the the latest obj of the array and a lot more.
But all did not feel right.
What is the best and correct way to create and use custom table view cells (with interface builder).
I think Storyboards are the new proper way. I use this method:
http://iphonedevelopment.blogspot.com/2009/09/table-view-cells-in-interface-builder.html
And it works quite well. I think it's somewhat proper in that you are asking the OS to do most of the work, although it's a little sneaky that the cell is assigned to a property as part of the NIB loading as a side effect.
Had the same problem. For me it is now solved with storyboards in ios5.

How does Apple use bold and normal fonts for a Contacts' name in ABPeoplePickerNavigationController

Short and sweet:My end goal is to, using one UILabel with two words, display one word in bold, and the other in normal font. All solutions I've found are over my head! :(
More detail:
I asked a question the other day that didn't give me the answer I was hoping for, and now it looks like I need to recreate ABPeoplePickerNavigationController using a UITableViewController and contents from ABAddressBook. If you read my previous question and can come up with a better solution, awesome! If not...
When I recreate the PeoplePicker, I really want to mimic Apple's default implementation exactly, especially how they use both bold and normal fonts for a contacts' name in the same label.
Now, I know this question has been asked a lot, on SO and elsewhere. Many people have had this need, and the solutions vary:
use a webview
use the UIStringDrawing methods
subclass UILabel and override drawrect
delve into CoreText
use the ThreeTwenty library
use two uilabels, create one as bold, one as normal, and place them next to each other (would require me to then subclass UITableViewCell in order to place two labels
Solutions #2, #3, and #4 seem the most robust, and according to what I've read in other questions, it's how Apple is actually doing it. Unfortunately, these techniques are a little over my head at the moment, and I'm having a hard time following the limited amount of details I'm finding on the web. I haven't really done anything with explicit drawing yet.
Has anybody implemented this yet themselves? Any code samples you can provide to help me get the hang of these more advanced techniques?
Thanks!
There's a 6th solution. Use 2 UILabels. Create one, in bold, with the bold text, and ask it to size to fit. Then once you've laid it out, you can create the second and place it right next to the first.
You should read the "Table View Programming Guide for iOS" there is a section titled "Subclassing UITableViewCell" it does exactly what you want (i.e. draw strings of different properties).
So, just to round this out, I ended up finding a 7th option. :)
I went with OHAttributedLabel. I still wasn't able to wrap my head around UIStringDrawing methods or overriding drawRect in a subclassed UILabel; I think those would have been the cleanest solution. However, OHAttributedLabel seems solid, is super lightweight, and does exactly what I need it to do.
Good luck! If anyone finds more solutions, or feels like they want to explain UIStringDrawing or or drawRect in more detail, feel free to post!
Update:
I've been using Matt Thompson's TTTAttributedLabel and have been really happy with it.
https://github.com/mattt/TTTAttributedLabel

NSOutlineview with images in cells

I'd like to add images next to my cells in my nsoutlineview.
I'm having a really tough time doing this. I'm coming from iPhone development, so I was thinking of making a custom cell to do this, but it seems like NSCell is a control, not a view.
I've looked at the SourceView sample code, but it's tremendously confusing. It seems like this should be a really simple task as it's such a common interface component.
I currently have a working nsoutlineview which only has text, and i've implemented the following delegate methods:
-outlineView:child:ofItem:
-outlineView:isItemExpandable:
-outlineView:numberOfChildrenOfItem:
-outlineView:objectValueForTableColumn:byItem:
-outlineView:setObjectValue:forTableColumn:byItem:
-outlineViewSelectionDidChange:
Check out PXSourceList. It does this (using custo drawing), so you can either just use it directly or rip the drawing code into your own app, etc.
Apple has an example on how to do this:
http://www.cocoadev.com/index.pl?NSTableViewImagesAndText