I am working on a project where i have used tableView to list numbers and had to set the tableView height according to its content size and further i have disabled the scroll of tableview to satisfy my design. But the problem is when i have disabled it the bounce effect also got disabled.
Is there is any way to give it a bounce effect and at a time disabling the scroll?
No. The bounce property of the UITableview works when scrolling is enabled.
So it is not possible to work it when scrolling is disabled.
Instead you can increase/decrease the height of the UITableview based on the rows.
Related
I want my app to have a view that can scroll even when there isn't always content to scroll to. For instance, the Wifi tab in settings is always scrollable. Is this a UIScrollView?
I'm using Storyboard, not SwiftUI by the way.
Thanks in advance for any suggestions!
I've tried using a UIScrollView but I think what I'm trying to achieve is different.
I think you're looking for the UIScrollView's alwaysBounceVertical property:
If the value of this property is true and bounces is true, the scroll view allows vertical dragging even if the content is smaller than the bounds of the scroll view. The default value is false.
The Settings app is using UITableView in "group" mode for most screens. The little bit of scrolling you can do even when there is little content is referred to as "bounce".
UIScrollView can also be used (UITableView extends UIScrollView). The bounce actually comes from the scroll view. You can enable the bounces property.
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.
If you look at the Featured tab of the Apple App Store app on an iPhone 6, there is a unique UI layout that I can't figure out how to replicate.
At the very top there is a navigationBar. Below this there is a UIScrollView that animates through a number of featured items. Below this is what appears to be a UITableView with a number of custom programmed cells.
My first guess was that the UIScrollView at the top was added to a custom cell at the top of a UITableView. If you swipe up the UIScrollView moves with the objects below like it is a cell. You can see that the vertical scroll indicator starts at the top of the UIScrollView.
The part that is unique is that if you swipe down, the objects below the UIScrollView move down like a UITableView and the UIScrollView stays in place. This means that the UIScrollView is not a custom cell at the top of a UITableView.
I tried making this work a number of different ways but I can replicate this. Does anyone know how this can be done?
You can use a tableview header,the header is a scrollview
If you scroll tableview up,just use tableview default behavior,the header will scroll up.
If you scroll down,use UIScrollViewDelegate to calculate the tableview header new frame,and adjust it.So it remain at top
Not sure if I got you correctly, you may use UICollectionView as vertical scroll. Then, you create a custom UICollectionViewCell, each with horizontal scroll.
I haven't tried it though but done something similar to this. Hope you find a way!
The UICollectionView disables scrolling by default when there is not enough cells in the view. When this occurs I need it to bounce back to position when pulled. Im am aware of a hack where I can fill the UICollectionView with empty tables to enable scrolling but I was hoping there would be a slightly more fluid example as
I don't want the view to scroll but instead to automatically bounce back to its position. This is because of the effect I have implemented below as can see below.
https://youtu.be/r75xB9-Mb4g
Is there a way to achieve this simply, when there is not enough cells in the UICollectionView the scroll is disabled.
For vertical scrolling:
self.collectionView.alwaysBounceVertical = true;
For horizontal scrolling:
self.collectionView.alwaysBounceHorizontal = true;
I'v some strings of different size in an array, i added them to UIScrollView by using UILabel
user can scroll horizontally to see all the names.But i want when user scroll either side he should see next/previous name from list as we do in paging enabled scroll view but here i want only one name(of different size) to be scrolled, not the whole screen.How to achieve this?Any help or suggestion would be highly appreciated.
Edit: - for better understanding suppose initially 0th, 1st and 2nd strings from my array is visible on scroll view, and when user scroll it should show 1st, 2nd and 3rd strings from my array(and vice versa for scrolling to other side).
You can do this by contentoffset.
set contentoffset of scrollview and you can able to do this.