2013-10-25 25 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