Tôi đang gặp phải một số vấn đề trong việc tích hợp phân đoạn và giao thức trong khi triển khai danh sách lựa chọn.Truy cập đúng bộ điều khiển xem đích của segue để gán các đại biểu giao thức
Trong danh sách lựa chọn của tôi .h tôi có:
#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
Trong danh sách lựa chọn .m của tôi, tôi có:
@implementation SelectColori
@synthesize delegate;
//this method is called from a button on ui
-(IBAction)saveSelectedColore
{
[self.delegate rowChosen:[lastIndexPath row]];
[self.navigationController popViewControllerAnimated:YES];
}
tôi muốn truy cập để xem danh sách lựa chọn này bằng cách thực hiện một segue từ một chế độ xem bảng khác:
@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];
}
Nếu tôi điều hướng đến danh sách lựa chọn bằng cách sử dụng:
[self.navigationController pushViewController: selectController animated: YES];
thông báo được hiển thị. Nếu tôi sử dụng thay thế:
[self performSegueWithIdentifier: @ "SelectColorSegue" sender: self];
không có cảnh báo nào được hiển thị, bởi vì, tôi nghĩ, tôi không chuyển đến danh sách lựa chọn đích selectController. Bất kỳ ý tưởng để giải quyết vấn đề này xin vui lòng?
Nó hoạt động như một sự quyến rũ cảm ơn bạn! :) – yassassin