UISplitViewConroller가있는 범용 앱이 있습니다. 스토리 보드를 사용하고 있습니다.iOS5 StoryBoard에서 대리자가 설정되지 않음 UISplitViewController
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *masterNavigationController = [splitViewController.viewControllers objectAtIndex:0];
LeftViewContrller *lcontroller = (LeftViewContrller *)masterNavigationController.topViewController;
id<SplitViewDelegate> rightController = (id<SplitViewDelegate>)[splitViewController.viewControllers objectAtIndex:1];
lcontroller.delegate = rightController;
}
저는 UISplitViewController 응용 프로그램의 왼쪽 및 오른쪽 컨트롤러가 있습니다.
LeftViewController에는 RightViewController로 설정된 사용자 지정 대리자가 있습니다.
//Custom delegate
@protocol SplitViewDelegate <NSObject>
- (void) matchSelectionChanged:(NSString *)curSelection;
@end
//LeftViewContoller
@interface LeftViewContrller : UITableViewController {
id<SplitViewDelegate> _delegate;
NSMutableArray *_matches;
}
@property (strong) id<SplitViewDelegate> delegate;
@property (strong) NSMutableArray *matches;
@end
RightViewController는이 위임 프로토콜을 구현합니다. 그러나, 셀 안쪽 행이 LeftViewController에서 클릭되면 대리자가 실패합니다.
//RightViewController
@interface RightViewController : UIViewController <SplitViewDelegate>
@property (weak,nonatomic) IBOutlet UILabel *matchLabel;
@end
//Implementation of RightViewController
- (void) matchSelectionChanged:(NSString *)curSelection {
self.matchLabel.text = curSelection;
//[self refresh];
}
//Did select row in LeftViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableString *s = [[NSMutableString alloc] initWithString:@"Row selected"];
if (_delegate != nil) {
[s appendFormat:@" %d ", indexPath.row];
[_delegate matchSelectionChanged:s];
}
}
// 받기 CustomViewTab [1200 : 11303] 오류로 인해 캐치되지 않는 예외 'NSInvalidArgumentException'응용 프로그램 종료, 이유는 *이 - * '[UINavigationController가 matchSelectionChanged이 :] 알 수없는 선택 예를 0xda6a770로 전송' 먼저 던져 호출 스택 : (0x1559052 0x1da8d0a 0x155aced 0x14bff00 0x14bfce2 0x1204e 0x62071d 0x620952 0x25986d 0x152d966 0x152d407 0x14907c0 0x148fdb4 0x148fccb 0x2500879 0x250093e 0x590a9b 0x1df8 0x1d55) 내가 didSel를 참조 예외
을 던지는라고 종료 ectRowAtIndex가 호출되었지만 RightViewController의 matchSelectionChanged : (NSString *)은 curSelection이 호출되지 않습니다.