alibaba / VirtualView-iOS

A solution to create & release UI component dynamically.
MIT License
507 stars 77 forks source link

VVGridView的setUpdateDelegate:方法存在隐患 #4

Closed zekunyan closed 6 years ago

zekunyan commented 6 years ago

https://github.com/alibaba/VirtualView-iOS/blob/290e44426e00af75d2fad7e95ef27e80b5daaa04/VirtualView/View/VVGridView.m#L440

- (void)setUpdateDelegate:(id<VVWidgetAction>)delegate{
    if (self.drawLayer==nil) {
        self.drawLayer = [VVLayer layer];
        self.drawLayer.drawsAsynchronously = YES;
        self.drawLayer.contentsScale = [[UIScreen mainScreen] scale];
        self.drawLayer.delegate =  (id<CALayerDelegate>)self;
        [self.gridContainer.layer addSublayer:self.drawLayer];
    }
    for (VVViewObject* subObj in self.subViews) {
        subObj.updateDelegate = (id<VVWidgetAction>)self.gridContainer;
    }
}

其中if (self.drawLayer==nil)永远为NO,因为继承的VVLayout会保证self.drawLayer有值

然后

subObj.updateDelegate = (id<VVWidgetAction>)self.gridContainer

非常危险,因为self.gridContainer没有实现VVWidgetAction

zekunyan commented 6 years ago

同理VVPageView也有这个问题

HarrisonXi commented 6 years ago

收到,这是 Layout 重构进行到一半导致的 bug,会在重构中尽快解决。

HarrisonXi commented 6 years ago

1ddad863080dc325ee1645882f7857c8cb64f28e 将 drawLayer 稍微改进了下,不过不确定是否完全解决了此问题

HarrisonXi commented 6 years ago

release 1.2.2 已解决