当前位置: 代码迷 >> Iphone >> 请教 定义局部变量 _block是什么意思
  详细解决方案

请教 定义局部变量 _block是什么意思

热度:114   发布时间:2016-04-25 06:45:36.0
请问 定义局部变量 __block是什么意思?
//帮助页面  
- (void)setupHelpview{
  __block UIImageView *helpImageView = (UIImageView *)[self.view viewWithTag:kHelpViewTag];
  if (!helpImageView) {
  UIImage *helpImage = [UIImage imageNamed:@"detail_help.png"];
  UIImageView *helpView = [[[UIImageView alloc]initWithImage:helpImage ] autorelease];
  helpView.center = self.view.center;
  helpView.center = CGPointMake(helpView.center.x *3, helpView.center.y);
  helpView.tag = kHelpViewTag;
  [self.view insertSubview:helpView belowSubview:self.headerView];
  [UIView animateWithDuration:0.5 animations:^{
  self.pageVC.view.center = CGPointMake(self.pageVC.view.center.x - self.pageVC.view.frame.size.width, self.pageVC.view.center.y);
  helpView.center = CGPointMake(helpView.center.x/3, helpView.center.y);
  } completion:^(BOOL finished){
   
  }];
  }else{
  [UIView animateWithDuration:0.5 animations:^{
  self.pageVC.view.center = CGPointMake( self.pageVC.view.center.x + self.pageVC.view.frame.size.width, self.pageVC.view.center.y);
  helpImageView.center = CGPointMake(helpImageView.center.x *3, helpImageView.center.y);
  } completion:^(BOOL finished){
  [helpImageView removeFromSuperview];
  helpImageView = nil;

  }];
  }

}
像这样定义
 


------解决方案--------------------
http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Blocks/Articles/00_Introduction.html
文档说明很详细
------解决方案--------------------
记得是表示一段代码可以放进去的。
  相关解决方案