ios block 导致的循环引用

[[NSNotificationCenter defaultCenter] addObserverForName:@"UIWindowDidRotateNotification" object:self queue:nil usingBlock:^(NSNotification *note) {
        if ([note.userInfo[@"UIWindowOldOrientationUserInfoKey"] intValue] >= 3) {
            self.navigationController.navigationBar.frame = (CGRect){0, 0, self.view.frame.size.width, 64};
        }
    }];

今天在controller里加了上面的代码,发现不能controller不能释放了,不是因为没有调用

[[NSNotificationCenter defaultCenter] removeObserver:self];

即使调用了上面的代码也没用!

原来又是忘记在block中要用 weak self,不能用self,这里的问题需要仔细想一下再记下来。。。

posted @ 2015-12-07 14:25  幻化成疯  阅读(215)  评论(0编辑  收藏  举报