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
I had the same problem. Solved it by using a custom segue. In the class's prepare
method:
UITableViewController
UIPopoverController
initialized with the destination controllerframe
as the CGRect
Here's some sample code:
UITableViewController *tvc = (UITableViewController *)self.sourceViewController;
DetailsViewController *details = (DetailsViewController *)self.destinationViewController;
UITableViewCell *cell = [tvc.tableView cellForRowAtIndexPath:[tvc.tableView indexPathForSelectedRow]];
UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:details];
details.popoverController = pop;
CGSize size = CGSizeMake(640, 460);
pop.popoverContentSize = size;
[pop presentPopoverFromRect:cell.frame
inView:tvc.tableView
permittedArrowDirections:UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown
animated:YES];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With