Я сталкиваюсь с некоторыми проблемами в интеграции segue и протоколов при реализации списка выбора.Правильный доступ к контроллеру представления назначения segue для назначения делегатов протокола
В моем списке выбора .h у меня есть:
#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
В моем списке выбора ого у меня есть:
@implementation SelectColori
@synthesize delegate;
//this method is called from a button on ui
-(IBAction)saveSelectedColore
{
[self.delegate rowChosen:[lastIndexPath row]];
[self.navigationController popViewControllerAnimated:YES];
}
Я хотел бы получить доступ к этой точке зрения списка выбора, выполняя SEGUE с другой точки зрения таблицы:
@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];
}
Если я перейти к списку выбора, используя:
[self.navigationController pushViewController: selectController animated: YES];
отображается предупреждение. Если я вместо этого использую:
[self performSegueWithIdentifier: @ "SelectColorSegue" отправитель: self];
не отображается предупреждение, потому что, я думаю, я не перехожу к списку выбора пункта selectController. Любые идеи для решения этой проблемы, пожалуйста?
Это сработало, как шарм, спасибо! :) – yassassin