YZPullDownMenu.m中解决循环引用问题#4
Open
CoderHRXu wants to merge 2 commits into
Open
Conversation
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
之前有打过断点,在viewcontroller的dealloc方法,lldb调试,发现添加的子控制还是存在,就算主动调用removeFromParentViewController还是不会释放,导致从导航控制器pushu第二次过来,更改标题发通知的时候,object为self,传是第一次push进来的内存地址,然后就是去索引取不到,取按钮就会报错数组越界。NSInteger col = [Weakself.controllers indexOfObject:note.object];UIButton *btn = Weakself.menuButtons[col]; 经查证是因为YZPullDownMenu.m处理通知监听使用的block,在block中self.controllers会强引用子控制器。把block处理通知替换成指定方法就OK了。viewcontroller的dealloc时候子控制器也释放,下次导航控制器push的时候就没事了