Me encuentro con algunos problemas para integrar segue y protocolos al implementar una lista de selección.Acceso apropiado a un controlador de vista de destino de segue para asignar delegados de protocolo
En mi lista de selección .h tengo:
#import <UIKit/UIKit.h>
@protocol SelectionListViewControllerDelegate <NSObject>
@required
- (void)rowChosen:(NSInteger)row;
@end
@interface SelectColor : UITableViewController <NSFetchedResultsControllerDelegate>
-(IBAction)saveSelectedColor;
@property (nonatomic, strong) id <SelectionListViewControllerDelegate> delegate;
@end
En mi lista de selección .m que tengo:
@implementation SelectColori
@synthesize delegate;
//this method is called from a button on ui
-(IBAction)saveSelectedColore
{
[self.delegate rowChosen:[lastIndexPath row]];
[self.navigationController popViewControllerAnimated:YES];
}
me gustaría acceder a esta vista de la lista de selección mediante la realización de un segue desde otro punto de vista tabla:
@implementation TableList
...
- (void)selectNewColor
{
SelectColor *selectController = [[SelectColor alloc] init];
selectController.delegate = (id)self;
[self.navigationController pushViewController:selectController animated:YES];
//execute segue programmatically
//[self performSegueWithIdentifier: @"SelectColorSegue" sender: self];
}
- (void)rowChosen:(NSInteger)row
{
UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error Title" message:@"Error Text" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
Si navego a la lista de selección usando:
[self.navigationController pushViewController: selectController animation: YES];
se muestra la alerta. Si uso en su lugar:
[self performSegueWithIdentifier: @ "SelectColorSegue" remitente: self];
no se muestra ninguna alerta, porque, creo, no paso a la lista de selección de destino seleccionar control. Alguna idea para resolver este problema, por favor?
¡Funcionó como un encanto, gracias! :) – yassassin