0

I would like to implement a fullscreen UITableView in my app which would show only one cell at a time with an image. On top of each cell, I would like to have a few labels with fixed positions, so that when the user swipes to the next cell they stay on their place, only get updated.

What would be the most effective way to implement such functionality?

That's how I would like the end result to look:

enter image description here

narolski
  • 193
  • 1
  • 1
  • 11

3 Answers3

1

You probably don't need UITableView. You might do something similar to this in your full screen view:


Few labels (UILabel objects)


Scroll view with UIPageViewController with vertical transition


This way topmost part with labels would stay intact and you will just update text there, and UIPageViewControll will be responsible for scrolling images back and forth.

sha
  • 17,824
  • 5
  • 63
  • 98
0

A bit more clarity:

First, the UITableView should not be full-screen if you intend to have a row of labels across the top. It would seem to make more sense to place your labels across the top (or bottom, or where ever) and then place your tableView below/above/beside. As a table cell is selected, update the labels as appropriate.

Now, tell us this: Will this table have only a single row? If so, rather than use a UITableView, why not use a UIPickerView (also placed below/above/beside the labels). A UIPickerView would accomplish the same thing, only in a vertical representation. Swipe up/down is already built in for you, and where ever it stops, that is the row that is selected. Now, when a row is selected, take action to update external labels as appropriate.

Hope this helps...and happy coding!

TheTwoNotes
  • 453
  • 3
  • 15
  • I've just uploaded a GIF that may clarify things a little bit. The table will have only a single row, in which it would show an image downloaded from Parse. – narolski Oct 13 '14 at 21:19
  • Okay, so you are scrolling up and down (the exact thing a UIPickerView would do). Put images (maybe custom objects) into the UIPickerView and make each one a full-screen size. When the pickerView stops on a row, update the label(s). – TheTwoNotes Oct 13 '14 at 21:28
  • Thanks, I'll try that! The only thing I'm concerned about is a subview for each element - I know that this functionality would be easy to implement when using uitableview, but how about the picker? – narolski Oct 13 '14 at 21:29
  • And actually, I like the answer sha gave below. You would need to implement your own swipe logic (but that is really nothing) and the transitioning vertical is a breeze too. I think we both agree, the UITable is not the correct UI. I'm voting for sha's answer, but do what works and is easy to maintain going forward. – TheTwoNotes Oct 13 '14 at 21:32
0

You can do this with a full height table view. Just add it in a UIView controller, and add the label to the view controller's view (not to the table view) also. Set paging enabled for your table, and set the row height to the height of the table view. You can get the row of the visible cell with this code, and do whatever you want with that number to update your label,

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    NSArray *paths = self.tableView.indexPathsForVisibleRows;
    NSInteger row = [paths[0] row];
    ContainerViewController *parent = (ContainerViewController *)self.parentViewController;
    parent.label.text = [NSString stringWithFormat:@"This is picture %d", row];
}
rdelmar
  • 103,982
  • 12
  • 207
  • 218
  • Thanks! The problem is that I have to use the PFQueryTableViewController subclass for UITableViewController to get data from Parse cloud, and I can't figure out how to acheive that when I embed UITableView inside UIViewController. – narolski Oct 14 '14 at 10:53
  • @maxster256, that makes it slightly more complicated, but still easily doable. You need to have an initial view controller to which you add a full sized container view. Embed the PFQueryTableViewController in that container view, and add the label to the container controller's view. In the PFQueryTableViewController, import the container view controller's class, and use the modified code in my answer. – rdelmar Oct 14 '14 at 16:04