Ios popover segue上无法识别的选择器

Ios popover segue上无法识别的选择器,ios,objective-c,uiviewcontroller,uinavigationcontroller,segue,Ios,Objective C,Uiviewcontroller,Uinavigationcontroller,Segue,我在我的应用程序中使用此代码通过相应的顺序传递数据: -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"readMoreDetail"]) { MoreViewController *destinationViewController = segue.destinationViewController; dest

我在我的应用程序中使用此代码通过相应的顺序传递数据:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"readMoreDetail"]) {
    MoreViewController *destinationViewController = segue.destinationViewController;
    destinationViewController.openSubject = [self.detailItem description];
} else if ([segue.identifier isEqualToString:@"notesSegue"]) {
    NSLog(@"segue");
    NotesTableViewController *destinationViewController = segue.destinationViewController;
         destinationViewController.openSubject = [self.detailItem description];
    } else {
        // Do nothing
    }
}
我在NavigationController中嵌入了一个UIViewController,并创建了一个从另一个UIViewController到NavigationController的popover segue-但是当我导航时,我收到以下错误:

-[UINavigationController setOpenSubject:]: unrecognized selector sent to instance 0x15e532a0
你知道为什么吗

谢谢

NotesTableViewController.h

#import <UIKit/UIKit.h>

@interface NotesTableViewController : UITableViewController <UINavigationControllerDelegate>

@property(nonatomic, strong)NSString *openSubject;

@end

(我相信每个人都不会窃取此代码)

确保您的序列标识符正确标识为“notesSegue”和“readMoreDetail”,有时您必须清理项目并再次运行它


如果触发到
UINavigationController
的序列,则
segue.destinationViewController
将是导航控制器,而不是导航控制器中包含的视图控制器

但是,您可以获得对
NotesTableViewController
的引用:

UINavigationController *navController = segue.destinationViewController;
NotesTableViewController *notesTableVC = (NotesTableViewController *)[navController topViewController];
然后你可以使用

notesTableVC.openSubject = [self.detailItem description];

等等,在您的
NotesTableViewController

中设置属性,我已经检查过了-操作确实会在NSLog也记录时触发,但这一行被指责:destinationViewController.openSubject=[self.detailItem description];发布您的Notestablevewcontroller。你是怎么开始openSubject的@user3653447@user3653447看起来不错。好奇“[self.detailItem description]”是否返回非字符串的内容,从而导致无法识别的选择器错误。尝试NSLog“[self.detailItem description]”NSLog会记录一个字符串,就像它应该记录的那样:)很高兴知道您在@user3653447处找到了答案,方法是:Stackoverflow上的所有用户帖子都是根据此许可证发布的。因此,每个人都可以自由地
窃取
你发布的代码…基本上,你在某处称之为NotesTableViewController的东西不是。如果您查看异常下面的堆栈跟踪,您将被指向错误行。现在尝试了,但它说:“UINavigationController”的No visible@interface声明了“rootViewController”的选择器好的,该属性似乎不存在。更新了我的答案。请改为尝试
topViewController
。或者-如果导航堆栈中有其他视图控制器-
[[navController viewControllers]objectAtIndex:0]
notesTableVC.openSubject = [self.detailItem description];