iOS Grid View with support for different sized cells - iphone

I'm an iOS developer looking for a solution to a tricky problem.
I need to create a grid view/ mosaic view to layout cells of different sizes (both width and height).
I basically need the functionality of a GMGridView, with horizontal scrolling/paging, the ability to edit, and drag cells to new locations, thus rearranging the entire grid view. I've looked at all of the current open source grid views out there, and found none with variable sized cells.
One solution I have thought about is 2 tableviews both rotated for the horizontal scrolling, and then intercept some UITableView scrolling methods, to then scroll the other tableview together. This is not ideal, as I will be unable to move a cell from one view to another, and I'm not sure how happy apple will be about it.
I also know of some possible (confidential?) support for this coming in the next version of iOS, but would like to keep my app supporting previous versions of iOS.
Thanks for any insight you can provide.

I realize this post is kind of old, but here is a list of relevant projects: *https://github.com/betzerra/MosaicUI
*https://github.com/betzerra/MosaicLayout

GridViews on iOS are a pain. Fortunately Apple is coming up with UICollectionViews that are optimized to build grids. This is coming in iOS6 and it's still under NDA so check out the documentation on Apple's website for more information.
The question you need to solve now is whether you want iOS5 retro-compatibility or not

Related

How can I make a grid similar to iphone/ipads launcher screen?

I have seen a few grids made with UITableView but I don't really like how close together each cell is to the other. If there is a way of creating a grid system like the home screen on an iphone (the screen after it is unlocked) if would be great. I don't need an exact solution but a point in the right direction, maybe a set of libraries to look through would be great. I am running xcode 4.4.1
Thanks!
The key is UIScrollView has a paging mode (since could have more buttons than fit in the view). It's covered here's in Apple ocs:
http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/ScrollViewPagingMode/ScrollViewPagingMode.html
If you use that, each 'page' would have n buttons/views that when clicked would call a protocol/delegate call back for the consumer with the data to handle and it would evenly layout the UIView/buttons across that page view. Contact me if you want my sample.
You probably don't want to require iOS6 as a minimum requirement but if you do, you can do as H2CO3 suggested in the comment and us UICollectionview. Here's a tutorial: http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12
There's also some open source launchers that you can look into their code. Here's some (I'm sure there's more).
http://www.cocoacontrols.com/platforms/ios/controls/sespringboard
Code is at: https://github.com/sarperdag/SESpringBoard
Also: http://www.cocoacontrols.com/platforms/ios/controls/openspringboard
Use UICollectionView. You can create grid type views using that. It is available in iOS 6.
If you can target iOS 6+, use UICollectionView. It's one of the best new things in iOS for years and it will be as important as UITableView.
The layout you're asking for is only a few lines of code.
NSHipster has a good explanation of UICollectionViews and Ray Wenderlich has a good tutorial.
(There's lots of example code out there, but here's a very simple example project I did recently for another question involving UICollectionViews)

Reasons why UITableView doesn't show scrollers

I have a NavigationController that stacks UIViewcontrollers that have UITableView among other UI elmeents. The tables I use are actually custom tables that use custom cell views. With this arrangement those tables don't show scrollbars of any kind even though I have configured in IB the Shows Vertical Scrollers to show them.
I've tried several ways of debugging this without success. If I print to console the value of this property (showsVerticalScrollers), it prints 1, so the property is properly set, and no, my table is not wider than its parent view, actually it's way more narrow than its parent view.
Are there reasons why a table won't show it's scrolls?... btw, this happens in iOS5 running in simulator. I'm using xcode 4.2 with SLeopard. I don't have access to an iPad to test it in the hardware but other tables I have in the same project, show their scroll bars without a problem.
EDIT
thanks for the answer... I did one last test and found that one of the causes for not showing a scrollbar is the number of elements shown in the table, when they fit in it without the need to actually scroll. Say if you have a table with 1 row and the vertical size of the table is too big for just one row?, then iOS won't show the scrollbar when bouncing.
It's hard to provide a possible solution without seeing any code, but the advice I can offer is to update your code to the bare minimum needed code to implement a UITableView and see if scrolling works, if it does, add in functionality in small increments, testing the scrolling with each new code addition till you reach the point that scrolling breaks. Incremental testing in this fashion helps to avoid issues like this where you are unable to effectively debug your application.

Creating a tableview in the form of a 'film strip'

I am developing an RSS-reader-type application. I am toying with the possibility of using a normal TableView application but showing the articles as a film-strip. I am mainly thinking for an iPad application (but possible it works on the smaller iPhone as well).
The idea is to have the cells passing/scrolling across the screen using swipe touches (but horizontal, and not vertical as with the normal TableView). They will be some-kind of miniatures of the full article, and when tapped (or with multi-touch zoom to have better control) can be enlarged to read. Then can then just be be moved on as soon as the user has seen enough of it.
Does anybody know if there is an easy way of accomplishing something like that?
The most obvious solution that springs to mind would be to use a UIScrollView, as this will provide the inertial effects, etc. for free - all you'd have to do it populate it with the relevant sub-views. (UITableView's actually use a UIScrollView.)
For more information and sample code, see Apple's UIScrollView docs.
If you want horizontal scrolling, take a look at Jeremy Tregunna’s JScrollingRow. It’s open source under a public domain licence.

UIPickerView that scrolls horizontally on the iPhone?

I'm taking a look at this widget, and it appears to be a UIPickerView, however I haven't seen anything provided by the iPhone SDK API that allows for horizontal scrolling only. Mostly it's all done vertically. Also there appears to be a custom graphic around this picker, so it might not be that either.
I'm curious if anyone is able to determine if this is indeed a UIPickerView or perhaps a hacked up UIScrollView? The widget is handy -- and I like its use. I found it in some random groceries app in the app store.
Here is the screenshot:
Thanks all.
I'd definitely use iCarousel library:
https://github.com/nicklockwood/iCarousel
The library is really well documented, the code is clean and maintained.
That is totally custom. You could indeed do something of the sort overlaying an UIImageView and an UIScrollView. I'd guess it's a 100% custom. As with all programming, there are many ways to do any single thing.
As I recently posted in response to this question, a class for an iOS horizontal picker control (STHorizontalPicker) has just been posted on GitHub. It's nowhere near as sophisticated as UIPickerView, but it provides the basic functionality for picking numeric values and the underlying foundation is probably a good starting point for adding more sophisticated functionality (it's a UIScrollView containing a UIView with multiple CATextLayers for the markers).
It was designed to be used in UITableCellViews and currently looks like this:
This website has source code for a picker that is aligned horizontally without subclassing it.
That definitely looks like a custom component. I'd suggest getting the .app file off your iPhone, opening up the bundle, and looking to see if there's a xib file for that interface. You may get lucky and find the component sitting in there. My guess is that it's a subclass of UIScrollView, but of course there's no way I could be sure of that without personally knowing the developer or the codebase.
You will recognize pickers by their giant screen-gobbling footprint :-) This is most likely a horizontal UIScrollView with a series of fixed-width labels (or images). The tricky bit is to have the bezel on top with a transparent center pass touches back to the underlying scroll view. Or you can take the easy way out and overlay four image strips (for each edge) and leave the middle open so touch events go directly to the scroller.
It's a custom control, but it's really not that hard to build.

How to implement a large grid of cells in an iPhone application?

In reference to my previous question, I would like to know how to implement a large grid of cells in an iPhone application.
I'm working on an interface which would be similar to an Excel spreadsheet, with many rows and columns. Do I have to handle each cell separately? How can I handle user interaction in each cell?
Is there a standard way to create this type of control?
There is no real standard mechanism.
If all of the cells in a given row will always fit in the width of the screen, one way to do it would be to create a UITableViewCell with several UILabels and vertical separators between them. If all of these rows had "columns" of the same width, you would get the appearance of a grid.
If that isn't possible, it might be helpful to think about what the table view control truly is. A table view is just a scroll view that automatically adds, removes, and recycles its subviews so that only the ones that are visible at a given time are in memory. There is no reason you could not write a GridView control that did the same thing, but in two dimensions. It wouldn't be as easy as using the built-in table view, of course, but if the table view can't do what you need, well, that's why Apple isn't writing all the apps.
Sounds like the exact thing that UICollectionView was made for!
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UICollectionView_class/Reference/Reference.html
Look at my answer to this question: MS Excel type spreadsheet creation using objective-c for iOS app.
Basically there's no standard way to do this. You will need to made everything by hand and there's 3 ways to go:
Use a UIWebView and layout everything using html/js.
Modify a UICollectionView.
Make everything by hand using Core Data.