1 //block传值 2 __weak SubjectViewController *weakSelf = self;//解决强强引用的问题 3 cell.clickBlock = ^(AppItem *aItem){ 4 DetailViewController *dvc = [[DetailViewController alloc]init]; 5 dvc.applicationId = aItem.applicationId; 6 7 weakSelf.hidesBottomBarWhenPushed = YES; 8 [weakSelf.navigationController pushViewController:dvc animated:YES]; 9 weakSelf.hidesBottomBarWhenPushed = NO; 10 }; 11 12 13 14 //block的循环引用(你持有我,我持有你) 15 /* 16 1.self(controller) self.view 持有红色的view 17 2.因为使用了 block,红色的 view 持有self 18 */ 19 // self(控制器) -> self.view -> 红色的 view -> block -> self 20 21 22 __weak SecondViewController *tmpSelf = self; 23 [viewRed didBeganBlock:^(UIView *view) { 24 NSLog(@"began"); 25 tmpSelf.view.backgroundColor = [UIColor blueColor]; 26 } movedBlock:^(UIView *view) { 27 NSLog(@"move"); 28 } endBloac:^(UIView *view) { 29 NSLog(@"end"); 30 }];