Code Monkey home page Code Monkey logo

jjstockview's People

Contributors

jezzmemo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jjstockview's Issues

CPU爆了

  • (NSUInteger)countForStockView:(JJStockView*)stockView{
    return 300000;
    }
    当数据很大的时候 你的demo里的 titleCellForStockView 和 contentCellForStockView一直在创建对象,CPU直接爆了 ,请参考UITableView的处理机制,使用缓存,这个问题很严重

当拖动的开始点在ContentCell里面的Button时,感觉有点延迟。

看了下代码

  • (BOOL)touchesShouldCancelInContentView:(UIView *)view
    {
    if ( [view isKindOfClass:[UIButton class]] ) {
    return YES;
    }

    return [super touchesShouldCancelInContentView:view];
    }
    这么处理的,但是感觉还是延迟。

另外查了下,有些是这么处理的
//传递touch事件

  • (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
    {
    if(!self.dragging)

    {
    [[self nextResponder] touchesBegan:touches withEvent:event];
    }

    [super touchesBegan:touches withEvent:event];

    // NSLog(@"MyScrollView touch Began");
    }

  • (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
    if(!self.dragging)
    {
    [[self nextResponder] touchesMoved:touches withEvent:event];
    }
    [super touchesMoved:touches withEvent:event];
    }

  • (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
    {
    if(!self.dragging)
    {
    [[self nextResponder] touchesEnded:touches withEvent:event];
    }
    [super touchesEnded:touches withEvent:event];
    }

但是还是不行,之前没有做过这种类似的需求,请问这个是不是属于bug,或者有什么好办法吗?

作者你好,发现存在内存泄漏

JJStockView.m 第100行代码处:
发现在cell的block中直接引用tableView会造成内存泄漏,这是我更改后的代码
__weak typeof(self) weakSelf = self;
//FIXME:tableView有内存泄漏
__weak typeof(tableView) weakTableView = tableView;
[cell setRightContentTapBlock:^(JJStockViewCell* cell){
__strong typeof(self) strongSelf = weakSelf;
NSIndexPath* indexPath = [weakTableView indexPathForCell:cell];
if ([strongSelf.delegate respondsToSelector:@selector(didSelect:atRowPath:)]) {
[strongSelf.delegate didSelect:strongSelf atRowPath:indexPath.row];
}
}];

11

解决了

JJStockView.m第158行处复用有问题, 重复调用 reloadStockView 会创建多个titleView.

JJStockView第158处复用有问题, 重复调用 reloadStockView 会创建多个titleView,建议改成:

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *headerView = [self.stockTableView dequeueReusableHeaderFooterViewWithIdentifier:@"headView"];
    if (!headerView) {
        headerView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:@"headView"];
        headerView.frame = CGRectMake(0, 0, self.bounds.size.width, 40);
        headerView.backgroundColor = [UIColor whiteColor];
    }
    
    CGFloat regularWidth = 0.0f;
    CGFloat headHeight = 0.0f;

    if([self.delegate respondsToSelector:@selector(headRegularTitle:)]){
        UIView* regularView = [self.delegate headRegularTitle:self];
        [headerView addSubview:regularView];

        regularWidth = CGRectGetWidth(regularView.frame);
    }

    if([self.delegate respondsToSelector:@selector(heightForHeadTitle:)]){
        headHeight =  [self.delegate heightForHeadTitle:self];
    }

    [headerView addSubview:self.headScrollView];
    self.headScrollView.frame = CGRectMake(regularWidth,0,CGRectGetWidth(self.frame) - regularWidth,headHeight);

    if([self.delegate respondsToSelector:@selector(headTitle:)]){
        // 移除原有的,避免重复添加
        
        UIView *titleView = [self.headScrollView viewWithTag:10000];
        if (titleView) {
            [titleView removeFromSuperview];
        }
        UIView* newTitleView = [self.delegate headTitle:self];
        newTitleView.tag = 10000;
        [self.headScrollView addSubview:newTitleView];

        self.headScrollView.contentSize = CGSizeMake(CGRectGetWidth(titleView.frame), headHeight);
    }

    return headerView;
}

高度能自适应吗?

有俩问题

  1. cell的高度能自适应吗?
  2. 如果滑动控件只是tableview中某个分区的cell,要怎么用?

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.