Giter Site home page Giter Site logo

Comments (8)

zuomeng07 avatar zuomeng07 commented on May 22, 2024

#3 在你最新的分支上,怎么修改悬浮问题啊

from swipetableview.

liangdrime avatar liangdrime commented on May 22, 2024

你好,你录得视频,是在你没有把bar放在header上的时候吧?
如果把bar放在header了,相当于没有了bar,也就不存在悬停bar的情况了。只是在处理header的frame了。
我下载了你提供的demo,bar也没有悬停功能了。只是在左右滑动切换item的时候,顶部insert的计算还是以_swipeHeaderTopInset为准导致header下部停留在_swipeHeaderTopInset高度的位置。
你再看一下,咱俩统一一下问题点,然后我解决一下。

from swipetableview.

zuomeng07 avatar zuomeng07 commented on May 22, 2024

是的,应该是监听contentSize的时候

#if !defined(ST_PULLTOREFRESH_HEADER_HEIGHT)
            CGFloat topMarginOffset = _swipeHeaderTopInset + _barInset;
            DLog(@"newOffsetY -- %f", newOffsetY);
            DLog(@"topMarginOffset -- %f", topMarginOffset);
            // stick the bar
            if (newOffsetY < - topMarginOffset) {
                if (_swipeHeaderBar) {
                    _swipeHeaderBar.st_bottom  = - newOffsetY;
                    _swipeHeaderView.st_bottom = _swipeHeaderBar.st_top;
                }else {
                    _swipeHeaderView.st_bottom = - newOffsetY;
                }
            }else {
                _swipeHeaderBar.st_bottom  = topMarginOffset;
                // 'fmax' is used to fix the bug below iOS8.3 : the position of the bar will not correct when the swipeHeaderView is outside of the screen. 
                _swipeHeaderView.st_bottom = fmax(- (newOffsetY + _barInset), 0);
            }
#else

不知道我要根据什么去改变_swipeHeaderView.st_bottom,我如果创建swipeTableView,swipeHeaderTopInset为0时,header的底部是正常的,但是导航栏就会盖住视图上面的64了。我的导航栏高度是动态变化的,那是不是要动态设置swipeHeaderTopInset,但我又发现每次设置swipeHeaderTopInset时都会去reload。

from swipetableview.

liangdrime avatar liangdrime commented on May 22, 2024

如果是刚才我说的那个问题的话。那么现在有两个解决办法
首先说明一下,header与bar的悬停都是根据swipeHeaderTopInset来设置的,这个值属性就是为了给顶部留一个空白,一般是导航栏高度,而header与bar的位置总是要悬停在这个位置的。所以,根据你的需求需要做修改处理。

第一种,相对来说是笨方法,就是把swipeHeaderTopInset同样设置为0,这样header就会隐藏在导航栏下。为了解决这个问题,可以把自己定义的header的高度比自己需要的高度增加64,然后所有内部控件的布局的位置从64的高度开始。这样,虽然header的位置是在0,但是内容的位置却是在64的位置。

另一种,需要修改代码了。因为heade的位置是根据swipeHeaderTopInset来设置的,其中就是在滑动的时候adjust方法中计算的。而swipeHeaderTopInset,在cellforrow中,会根据这个数值给每个item顶部增加contentInset的top值的。所以,针对你的需求,这两处冲突了。
可以设置两个属性,一个负责在cellforrow中对每个item的contentInset的top值调整,一个负责在adjust计算中负责计算相邻item顶部的初始位置。这样,可以把swipeHeaderTopInset,作为contentInset的top值,设置另一个属性在adjust中作为计算顶部位置的值,替换adjust中的swipeHeaderTopInset,或者因为你的需求,可以简单粗暴的直接把adjust中的swipeHeaderTopInset替换为0即可。

from swipetableview.

liangdrime avatar liangdrime commented on May 22, 2024

刚刚测试了一下,在两个adjust中修改如下即可(注意:在lastIndex == index条件下,属于init初始化,这里的swipeHeaderTopInset不要改为0,如果你页面默认一开始是显示导航栏的)

- (void)adjustItemViewContentOffset:(UIScrollView *)itemView atIndex:(NSInteger)index fromLastItemView:(UIScrollView *)lastItemView lastIndex:(NSInteger)lastIndex {
    ......
    // 取出记录的offset
#if !defined(ST_PULLTOREFRESH_HEADER_HEIGHT)
    CGFloat topMarginOffsetY  = - (_swipeHeaderTopInset + _barInset);
#else
    CGFloat topMarginOffsetY  = _headerInset - 0;
#endif
    NSValue *offsetObj = [self.contentOffsetQuene objectForKey:@(index)];
    CGPoint itemContentOffset = [offsetObj CGPointValue];
    if (nil == offsetObj) {  // init
        itemContentOffset.y = topMarginOffsetY;
    }
    .....
}

如果,是自适应的contentsize也是充满屏幕,即使隐藏了导航栏,下面adjust contentsize的方法也要修改

- (void)adjustItemViewContentSize:(UIScrollView *)itemView atIndex:(NSInteger)index {
    // get the min required height of contentSize
#if !defined(ST_PULLTOREFRESH_HEADER_HEIGHT)
    CGFloat minRequireHeight = itemView.st_height - (0 + _barInset);
#else
    CGFloat minRequireHeight = itemView.st_height - 0 + _headerInset;
#endif
    .....

from swipetableview.

zuomeng07 avatar zuomeng07 commented on May 22, 2024

我试了第二种,你贴的代码是可以的,等一下我试试第一种,还是不改里面源码的好。多谢了,等一下我仔细读读你写的评论,再研究下源码。我也看了一上午源码,但是各种contentInset,offset ,contentSize,弄的有点晕。

from swipetableview.

liangdrime avatar liangdrime commented on May 22, 2024

写的还是不好,多见谅😃

from swipetableview.

zuomeng07 avatar zuomeng07 commented on May 22, 2024

太谦虚了,还要多谢你的及时回复。回复的好认真。。

from swipetableview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.