uibutton 对象传递

UIButton *btn = (UIButton *)[cell viewWithTag:101];
    btn.frame = CGRectMake(5, 5, 150, hei - 10);
    [btn addTarget:self action:@selector(selectPic:) forControlEvents:UIControlEventTouchUpInside];
    
    if ([indexPath section]==0) {
        picture = [guangPicLeftArray objectAtIndex:[indexPath row]];
    }else{
        picture = [guangPicRightArray objectAtIndex:[indexPath row]];
    }
  
    [picView setImageWithURL:[NSURL URLWithString:picture.picUrl]];
    [btn setImage:picView.image forState:UIButtonTypeCustom];
    //begin
    if (picture!=nil) {
         [btnToPicDic setObject:picture forKey:btn.description];
        NSLog(btn.description);
    }




- (void)selectPic:(UIButton *)aBtn{
    DetailViewController *detail = [[DetailViewController alloc]init];
    detail.picture = [btnToPicDic objectForKey:aBtn.description];
    [self presentModalViewController:detail animated:YES];
}

猜你喜欢

转载自longquan.iteye.com/blog/1684418