contentoffset

SwiftUI ScrollView with content frame update closure

£可爱£侵袭症+ 提交于 2019-12-13 20:49:23
问题 I want to have a ScrollView where you can be aware of the content frame changes as the user scrolls (similar to didScroll delegate in UIKit UIScrollView ). With this, you can then perform layout changes based on the scroll behavior. 回答1: I managed to come with a nice solution for this problem by making use of View Preferences as a method to notify layout information upstream in the View Hierarchy. For a very detail explanation of how View Preferences work, I will suggest reading this 3

UIScrollView's contentOffset being reset when clicking anywhere

落花浮王杯 提交于 2019-12-12 04:53:36
问题 I have an introduction sliding view pager type in my iOS app, and the last page has two text inputs. There are 7 pages being displayed in a scrollview that swipes left to right, so on the last page when the keyboard appears, I am having the contentOffset changed to push up the layout so the text inputs are still visible above the keyboard. Now anytime the user selects the next input, or even clicks really ANYWHERE on the page, the contentOffset is reset and the inputs are put back under the

How can I prevent jerky scrolling of UIScrollView if I have calculations in EndDecelerating,EndDragging and DidScroll?

孤街醉人 提交于 2019-12-11 16:42:03
问题 I have to update text of a label every time I scroll the UIScrollView...or everytime I scroll and leave it stop at a point on it's own. This updation of the text of the label is done based on the contentoffset of the scrollview. So now I am putting checks in each method : - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ int one = scrollView.contentOffset.x/21; int two = (21*one)+14; CGPoint point = CGPointMake(two, scrollView.contentOffset.y); [scrollView setContentOffset

IOS 中 contentsize contentoffset contentInset的区别

让人想犯罪 __ 提交于 2019-12-10 17:06:01
contentSize是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),代表你的scrollview可以上下滚动,滚动区域为frame大小的两倍。 contentOffset是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480 contentInset 是scrollview的contentview的顶点相对于scrollview的位置,例如你的 contentInset = (0 ,100),那么你的contentview就是从scrollview的(0 ,100)开始显示 另外UITableView是UIScrollView的子类,它们在上述属性又有所不同,tabelview的contentsize是由它的下列方法共同实现的 - (NSInteger)numberOfSections; - (NSInteger)numberOfRowsInSection:(NSInteger)section; - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

Animating the offset of the scrollView in a UICollectionView/UITableView causes prematurely disappearing cells

▼魔方 西西 提交于 2019-12-09 16:04:29
问题 We have a UICollectionView with a custom layout very similar to UITableView (it scrolls vertically). The UICollectionView displays only 3 cells simultaneously, with one of them being the currently active cell: [ 1 ] [*2*] [ 3 ] (The active cell here is #2.) The cells are roughly 280 points high, so only the active cell is fully visible on the screen. The user doesn't directly scroll the view to navigate, instead, she swipes the active cell horizontally to advance to the next cell. We then do

Get current position of UIScrollView

偶尔善良 提交于 2019-12-08 19:16:44
问题 I'm coming from Android and i'm getting a lot of headache in IOS. I need to make a scroll menu like a movie credits. I used the code below: rol = scroll_view.contentOffset.y; timer = [NSTimer scheduledTimerWithTimeInterval:.02 target:self selector:@selector(timer_rol) userInfo:nil repeats:YES]; -(void)timer_rol{ [scroll_view setContentOffset:CGPointMake(0,rol) animated:YES]; rol++; } This code works fine, but when the user interact scrolling up or down, the view return to position before

UIScrollView: More accurate/precise contentOffset value?

扶醉桌前 提交于 2019-12-07 12:20:54
问题 I was wondering if there is any way to get a more accurate version of the contentOffset , or estimate/calculate the contentOffset or (preferably) the first derivative of contentOffset of a UIScrollView . I am trying to perform an action when the rate of change of the contentOffset of my UIScrollView is very small, but 0.5f isn't quite precise enough. Any help is greatly appreciated. 回答1: You can't get better precision than the one provided by contentOffset . You could calculate velocity using

UICollectionView contentOffset changes when keyboard appears

点点圈 提交于 2019-12-07 01:54:08
问题 I am trying to implement PullDown To Search feature in my app. To implement this i just modified bit EGOTableViewPullRefresh it is working good except an issue. Issue When user opens the application following screen shall appear. initially the UICollectionView's contentoffset shall be (0,0) If user pulls down the collection view the following screen shall appear at this point the contentoffset of UICollectionView shall be (0,-60) User can search by entering their text in the above screen. My

UIScrollView: More accurate/precise contentOffset value?

谁说胖子不能爱 提交于 2019-12-05 22:03:00
I was wondering if there is any way to get a more accurate version of the contentOffset , or estimate/calculate the contentOffset or (preferably) the first derivative of contentOffset of a UIScrollView . I am trying to perform an action when the rate of change of the contentOffset of my UIScrollView is very small, but 0.5f isn't quite precise enough. Any help is greatly appreciated. You can't get better precision than the one provided by contentOffset . You could calculate velocity using regular ds/dt equation: - (void)scrollViewDidScroll:(UIScrollView *)scrollView { static CGFloat prevPos = 0

UICollectionView contentOffset changes when keyboard appears

我的梦境 提交于 2019-12-05 08:03:04
I am trying to implement PullDown To Search feature in my app. To implement this i just modified bit EGOTableViewPullRefresh it is working good except an issue. Issue When user opens the application following screen shall appear. initially the UICollectionView's contentoffset shall be (0,0) If user pulls down the collection view the following screen shall appear at this point the contentoffset of UICollectionView shall be (0,-60) User can search by entering their text in the above screen. My issue is occurring in this screen as soon as user taps the UITextField to enter text contentoffset of