2013-10-25 26 views
0

我想隐藏它没有数据的其他细胞,因为我填补了小区用户拍照。显示只有一格

例如

这是表视图细胞,作为用户需要的细胞应该建立基本上示出了所覆盖的小区的照片。

-------------------          1)------------------ 
          hiding the cell 
-------------------  -------------------->   ------------------- 

-------------------  

当用户拍摄照片的左侧表视图应该在右手边。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 

    UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage]; 

    self.thumbnails = image; 



    [self.imageView setImage:image]; 

    [self dismissViewControllerAnimated:YES completion:NULL]; 

    self.imagePickerController = nil; 

    [self.view addSubview:tableViewCell]; 
} 




- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 

    static NSString * CellIdentifier = @"CustomCell"; 

    CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if(cell == Nil){ 

     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil]; 
     cell = [nib objectAtIndex:0]; 
    } 

    UIImage *thumbnail = self.thumbnails; 
    cell.photoInfoLabel.text = @"New"; 
    cell.thumbnailImageView.image = thumbnail; 
    return cell; 
} 
+1

为什么不直接插入一个新的细胞一旦用户拍摄的图像? – sbarow

+0

如何一次插入一个单元? – TryingToLearn

回答

0

你可以通过调用

[tableView reloadData]; 

这将导致调用tableViews委托方法强制实现代码如下设置它的细胞:

// how many rows (or cells) are there 
- (NSInteger) tableView:(UITableView *)tableView 
    numberOfRowsInSection:(NSInteger)section; 

// create row/cell (or dequeue a reusable row/cell), set contents the row/cell 
- (UITableViewCell *)tableView:(UITableView *)tableView 
     cellForRowAtIndexPath:(NSIndexPath *)indexPath; 

您可以在您的viewController此方法来控制单元及其内容的数量。

0

插入一个新的细胞

-(void)imageCaptured 
{ 
    // NSMutableArray 
    [self.aTableContent addObject:@"Some Object"]; 

    // Table View 
    [self.aTableView beginUpdates]; 
    [self.aTableView insertRowsAtIndexPaths:@[ [NSIndexPath indexPathForRow:1 inSection:0] ] withRowAnimation:UITableViewRowAnimationAutomatic]; 
    [self.aTableView endUpdates]; 
} 
+0

真的没有越来越多。我已经更新了我的问题,也为我的相机界面使用了覆盖。 – TryingToLearn

+0

以[self.view addSubview:tableViewCell];出来并替换我上面添加的代码。 – sbarow

+0

我得到这个错误断言失败 - [UITableView的_endCellAnimationsWithContext:] – TryingToLearn