IOS animation in this video - ios

I am stuck in below task where I need similar animation in UITableView.
But I am also not sure what component used in this video (UITableView or UICollectionView)?
Animated component
Any leads highly appreciated

First up, there are multiple ways to implement this.
If the video shows the exact output you expect, you can achieve this with two UITableViews. One for the names on the bottom and one for the images on top.
Now, within the scrollViewDidScroll method, listen to the scroll changes within the tableView that contains the text and scroll the tableView with the images accordingly. If you're going for constant sized cells, the scroll coeffecient would be the sizeOfCellWithImage:sizeOfCellWithText

Related

Is there a way to change scrollview focus programatically?

In Swift, is there a way to change scrollview focus programatically? For example, in one of my scrollviews when a user is scrolling, after the scroll has gone past a certain distance I want the scroll to stop scrolling and to immediately scroll a tableview instead. I want this to all happen in the same motion/swipe, so I need to automatically shift the focus from the scrollview to the tableview using code. Is this possible?
Using Rikh's comment, I was able to solve this using a UITableView with multiple sections and custom UITableView headers. I can use the viewForHeaderInSection method to create a custom floating header which is exactly what I need and it scrolls much more smoothly.

Adding subview to UICollectionView - disables scrolling

I want to add a subview to a UICollectionView in order to make a left panel that scrolls with the collectionview.
Using
[self.collectionView addSubview:myView]
all touches become disabled and I can no longer scroll the view. I've read that adding a subview to a collectionView like this is bad practice.. is this true? Why does it disable touches from reaching the collectionView event when
userInteractionEnabled = NO
I'm trying to do this: imgur link by grabbing the frame position of the first cell in each section, and adding a dot with to myView with the same y value.
Thanks for any help!
Adding subviews using the addSubview: method to a UICollectionView is very bad practice. It can cause a lot of different problems in the normal behaviour of the CollectionView. It can obstruct the views underneath it, capture the touch events, preventing them from reaching the actual scrollView inside the CollectionView, etc. The subviews added using this method will also not scroll as the other elements in the CollectionView do.
The correct way to do what you want is to implement a new type of UICollectionViewCell for the dots, and compute their locations in the prepareForLayout and layoutAttributesForElementsInRect: methods. Basically you'll have either one or two cells in each row. Which ones will have two rows will be determined by you in the methods I've mentioned.
In fact, Apple's docs have a perfect example that's even more complex than what you're trying you achieve. You should check it out from this link.
May I know the purpose of that scroll view ? Because, if you're looking for a subview that displays only a label or image etc., You can use custom collectionview cell instead if I am not wrong... Hope it helps :) :)

UITableView Section Headers not visible when table in visible rect

I have a UIScrollView with 3 UITableViews stacked horizontally. I switch between these tableviews using a tab-controller on top. However, when I switch to the 2nd or 3rd tab and switch back quickly to 1st the section headers don't show. They display when I scroll the tableView. These are custom headers (jfyi). I tried calling setNeedsDisplay when the tableView is visible, but that does not help because as per Apple Docs :
If you simply change the geometry of the view, the view is typically not redrawn. Instead, its existing content is adjusted based on the value in the view’s contentMode property. Redisplaying the existing content improves performance by avoiding the need to redraw content that has not changed.
Since, only the geometry of the view is changing here, it does not help. Also this happens on all versions iOS 5~6.1 and on simulator and device. Thankfully, this does not crash the app, but its a problem nevertheless. Could someone help? I am attaching pictures for reference. First shows the problem, second: after scrolling the "head(er)less" tableview
EDIT:
I am using simple scrollRectToVisible:animated: to switch between tableviews. This does the trick but I just observed that when I set ...animated:NO all is okay. The problem happens when ...animated:YES
It seems the issue of displaying and scrolling taking place simultaneously for the respective tableview. So what you can do here is:
Remove the scroll animation
or
Just scroll the tableview to top on the tab press event
or
simply reload the tableView which is made visible

Imitate the combined horizontal and vertical scrolling in the iOS iTunes store

I'm trying to create a screen similar to that in the new iTunes store:
That is, a grid that's scrollable both horizontally and vertically.
The first approach I've tried involved creating a UITableView (for the vertical rows) and, within each UITableViewCell of that UITableView, another UITableView that's rotated 90 degrees.
This seems to work visually but I'm not able to scroll vertically. I believe the gesture recognizers from the subview tables are preventing the gesture recognizers from the parent table view from receiving touch events.
Basically, the rows scroll horizontally but not vertically.
The next approach I've thought then is to create UISrollViews for each row but I was wondering if there's something I've missed?
Has anyone else encountered this issue in the past?
I have done something similar to what you have with table view inside a table view, I made the rotated 90° table view the parent instead. I think I also had to turn off scrolling for one table views when scrolling is detected in the other table view, and visa-versa.
If your trying to target below iOS 6.0, ruling out using the UICollectionView, I would try using GMGridView:
https://github.com/gmoledina/GMGridView
It's very complete and has many features. It also has horizontal paging support which may achieve what you are looking for.
You should have a look at UICollectionView.
Never tried to build something like that but... Idea :
One tableview, n-cell, each cell embed a scrollView wich can contains, n-subviews.

With multiple UITableViews in a single UIScrollview, how to only load cell data for visible cells

I have 3 uitableviews in a single uiscrollview. Each uitableview is full length and not scrollable so that the outer uiscrollview scrolls them together. This works fine except the uitableviews believe all cells are visible so that all are created up front. Even this is acceptable except each call has an image view (a thumbnail) that is loaded asynchronously from a url. I am trying to figure out how to limit the image loading to only visible cells but still allow the user to scroll the outer uiscrollview (thus mimicking the uitableview behavior).
The alternative design of a single table with cells that show 3 cells each doesn't work (based on other design requirements) so I am stuck with some way to limit the image downloads. The largest number of cells will be 125 or so. The uiscrollview delegate doesn't seem to have enough calls to allow updating cells on the fly but I could be wrong. Any ideas?
Maybe just do a custom check : if the tableView is not visible (because not in the bounds of your scrollView), then do not load the images (or the cells) of the tableView in "cellForRowAtIndexPath".
If the tableView is visible, then call reloadData and display the images.
You can check all this with the scrollViewDelegate methods.
TableViewDatasource Protocol implements:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
for a full table that is not in bounds you can limit update simply by comparing the tableview pointer parameter to your actively showing tableviews and skip your non-visible tableviews.
For Cells: This is a more difficult one considering that you are implementing 3 on the same scrollview. This would be a bit easier if you implemented 3 separate tableviews each that are standardly implemented. The reason for this statements is, that the routine if implemented above by Apple's protocol really does only get called for the cells that are currently needing to be on screen. In this way you could implement your image background loader inside of the above defined routine, and you would indeed get what you wish. I have done this and it does work.
Another answer:
perhaps you should look into a custom tableview where you define your own custom look and feel for a single tableview that incorporates all the information you wish into this single table thus allowing you to implement the other half stated just above.
To give a better answer, I think I would have to dig deeper into what you are attempting to ultimately accomplish.
Appears I can simply use the UIScrollViewDelegate scrollViewDidScroll call and then use the scrollview's contentOffset.y to trigger the thumbnail for any cells which are visible (or about to be) using tableView indexPathsForRowsInRect for each tableview. My cell subclass has a method to trigger the thumbnail download.
The scrollViewDidScroll delegate method seems to be called for every pixel as you scroll which is perfect. I thought it might be too slow but so far it's not a big deal. The only issue to make sure I always check the visible cells if I sort them or something.

Resources