How do you build a 3 column layout of varying height images for the iphone
I need to create a screen that scrolls vertically - like the tablevie开发者_StackOverflow社区w but I need 3 columns and within those 3 columns I need to add images of varying height - so this will not fit into rows that a tableview can provide.
Should I create 3 tableviews and lay them out side by side - or something else. I think I could build this by simply positioning the images using coordinates but I wanted to benefit from methods that the table view can provide.
If you want the columns to act stuck together, so that they all scroll simultaneously, then I think best approach is to use UIScrollView
with the images added in the correct placed "by hand." UITableView and friends is not built to handle non-lined up columns.
added If you do use a UIScrollView
, and you have a large number of images you want to display (that is, the user can scroll for a long time), then it would be wise to recycle your UIImageView
objects that are scrolled off the screen. This is what UITableView
does with UITableViewCell
objects, and that's why UITableView
wins. You can win, too, if you code carefully.
Three table views would work, but in order to keep things neat and from the same datasource, I would consider using a subclassed UIPickerView and the UIPickerViewDelegate/UIPickerViewDataSource.
Particularly necessary methods:
// UIPickerViewDataSource
– numberOfComponentsInPickerView:
– pickerView:numberOfRowsInComponent:
// UIPickerViewDelegate
– pickerView:rowHeightForComponent:
- pickerView:viewForRow:forComponent:reusingView:
According to my opinion You should have to take three UITableView
in xib file and take its IBOutlet then give each UITableView
an unique tag and then implement UITableView's Delegate methods and in that Methods Check for Tag and then assign values.
Along With this, the other solution, you can also use UIPickerView and then implement UIPickerView's delegate methods also..
Happy Coding !!!
精彩评论