wangmchn / WMPageController

An easy solution to page controllers like NetEase News
MIT License
2.92k stars 627 forks source link

对象无法正常释放 #621

Open fangshufeng opened 4 years ago

fangshufeng commented 4 years ago

你好,反馈一个bug

- (void)setSelectIndex:(int)selectIndex {
    _selectIndex = selectIndex;
    _markedSelectIndex = kWMUndefinedIndex;
    if (self.menuView && _hasInited) {
        [self.menuView selectItemAtIndex:selectIndex];
    } else {
        _markedSelectIndex = selectIndex;
        UIViewController *vc = [self.memCache objectForKey:@(selectIndex)];
        if (!vc) {
            vc = [self initializeViewControllerAtIndex:selectIndex];
            [self.memCache setObject:vc forKey:@(selectIndex)];
        }
        self.currentViewController = vc;
    }
}

以上代码的else中没有对缓存策略的判断,当以下场景的时候会出现第一个对象无法释放

vc.cachePolicy = WMPageControllerCachePolicyDisabled;