Wednesday, April 18, 2012

Display a popover view from dynamic prototype cells

I'm developing an Ipad app with a custom split view. In the master view I have a tableViewController. I add items in this one with an add button in the navigation bar. This button is linked (i work with storyboard) with a popover segue to an other tableViewController that contains a few cells to enter datas. A button "save" dismiss the popover view an add item in the list of the masterView. What I want to do next is link master view's prototype cells to an other view to enable the user to edit the selected item. I want to link this view with a popover segue (just like with the add button) and there's where is the problème : I get an red issue from xcode : Couldn't compile connection: => anchorView => > .



This a sample of my code that works fine. I would like to do pretty the same when I tap on a cell for editing.



The masterSplitView table



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"assetCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// Configure the cell...
AssetModel *myAssetModel = [self.arrayAsset objectAtIndex:indexPath.row];
cell.textLabel.text = myAssetModel.name;
// cell.textLabel.text = @"test";

return cell;

}

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

if([segue.identifier isEqualToString:@"addAssetSegue"]){
AddAssetTVC *addAssetTVC = segue.destinationViewController;
addAssetTVC.delegate = self;

UIStoryboardPopoverSegue* popoverSegue = (UIStoryboardPopoverSegue*)segue;
[addAssetTVC setPopoverController:[popoverSegue popoverController]];

}

}

- (void) theSaveButtonOnTheAddAssetTVCWasTapped:(AddAssetTVC *)controller{
[controller.navigationController popViewControllerAnimated:YES];
[self reloadCache];
[self.tableView reloadData];
[self viewDidLoad];
}


And the save method of the add view :



- (IBAction)save:(id)sender{
[popoverController dismissPopoverAnimated:YES];
NSLog(@"Telling the ADDASSET Delegate that Save was tapped on the AddAssetTVC");

{...unrevelant coredata methods}

[self.delegate theSaveButtonOnTheAddAssetTVCWasTapped:self];
}


Thanks you for reading,



Alexandre





No comments:

Post a Comment