简体   繁体   English

无法识别的选择器已发送到实例0x6b61d10

[英]unrecognized selector sent to instance 0x6b61d10

I am practicing delegate in iphone development but have a problem 我正在iphone开发中练习委托,但是有问题

2012-05-12 21:21:54.279 DelegatePractice[2924:f803] -[secondViewController viewControllers]: unrecognized selector sent to instance 0x6b61d10 2012-05-12 21:21:54.281 DelegatePractice[2924:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[secondViewController viewControllers]: unrecognized selector sent to instance 0x6b61d10' * First throw call stack: (0x13bb052 0x154cd0a 0x13bcced 0x1321f00 0x1321ce2 0x2596 0x436e1e 0x13bcec9 0x155c2 0x250d54 0x13bcec9 0x155c2 0x1555a 0xbab76 0xbb03f 0xba2fe 0x3aa30 0x3ac56 0x21384 0x14aa9 0x12a5fa9 0x138f1c5 0x12f4022 0x12f290a 0x12f1db4 0x12f1ccb 0x12a4879 0x12a493e 0x12a9b 0x1e98 0x1df5) 2012-05-12 21:21:54.279 DelegatePractice [2924:f803]-[secondViewController viewControllers]:无法识别的选择器发送到实例0x6b61d10 2012-05-12 21:21:54.281 DelegatePractice [2924:f803] *由于未捕获而终止应用程序异常'NSInvalidArgumentException',原因是: ' - [secondViewController viewControllers]:无法识别的选择发送到实例0x6b61d10' *第一掷调用堆栈:(0x13bb052 0x154cd0a 0x13bcced 0x1321f00 0x1321ce2 0x2596 0x436e1e 0x13bcec9 0x155c2 0x250d54 0x13bcec9 0x155c2 0x1555a 0xbab76 0xbb03f 0xba2fe 0x3aa30 0x3ac56 0x21384 0x14aa9 0x12a5fa9 0x138f1c5 0x12f4022 0x12f290a 0x12f1db4 0x12f1ccb 0x12a4879 0x12a493e 0x12a9b 0x1e98 0x1df5)

and I think I set up the delegate properly: 我认为我正确设置了代表:

delegateViewController.m proxyViewController.m

- (void)secondViewControllerDidJump:
(secondViewController *)controller
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"jump"])
    {
        UINavigationController *navigationController = segue.destinationViewController;
        secondViewController *SecondViewController =[[navigationController viewControllers]objectAtIndex:0];
        SecondViewController.delegate = self;
    }
}

@end

secondViewController.h secondViewController.h

@class secondViewController;

@protocol SecondViewControllerDelegate <NSObject>
- (void)secondViewControllerDidJump: (secondViewController *)controller;

@end

@interface secondViewController : UITableViewController

@property (strong,nonatomic) NSArray *choices;
@property (nonatomic, weak) id <SecondViewControllerDelegate> delegate;

- (IBAction)jump:(id)sender;

@end

secondViewController.m secondViewController.m

- (IBAction)jump:(id)sender
{
    [self.delegate secondViewControllerDidJump:self];
}

Had the same issue, i solved by using: 有同样的问题,我通过使用以下方法解决了:

secondViewController *SecondViewController = segue.destinationViewController;

Basically segue.destinationViewController returns a view controller, so use it. 基本上,segue.destinationViewController返回一个视图控制器,因此请使用它。

Your app crashes in these lines: 您的应用在以下行中崩溃:

UINavigationController *navigationController = segue.destinationViewController;
secondViewController *SecondViewController =[[navigationController viewControllers]objectAtIndex:0];

You ask navigationController for its viewControllers , but the log makes clear that navigationController is not a UINavigationController but a secondViewController , which does not respond to the selector -viewControllers . 您向navigationController询问其viewControllers ,但日志清楚地表明navigationController 不是 UINavigationController而是secondViewController ,它不响应选择器-viewControllers

Make sure that segue.destinationViewController really returns a UINavigationController . 确保segue.destinationViewController确实返回UINavigationController

尝试这个

secondViewController *SecondViewController =[[self.navigationController viewControllers]objectAtIndex:0];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 [NSManagedObject 名称]:无法识别的选择器发送到实例 0x6b77240&#39; - [NSManagedObject name]: unrecognized selector sent to instance 0x6b77240' [UIView setText:]:无法识别的选择器已发送到实例0x89625d0 - [UIView setText:]: unrecognized selector sent to instance 0x89625d0 &#39;NSInvalidArgumentException&#39;:无法识别的选择器发送到实例0x8d25aa0&#39; - 'NSInvalidArgumentException': unrecognized selector sent to instance 0x8d25aa0' [__NSCFNumber 长度]:无法识别的选择器发送到实例 0x6d21350 - [__NSCFNumber length]: unrecognized selector sent to instance 0x6d21350 [UIProgressView setProgress:animated:]:无法识别的选择器已发送到实例0x5b34190&#39; - [UIProgressView setProgress:animated:]: unrecognized selector sent to instance 0x5b34190' [__NSCFDictionary isEqualToString:]:无法识别的选择器发送到实例0x6b7e510&#39; - [__NSCFDictionary isEqualToString:]: unrecognized selector sent to instance 0x6b7e510' [viewcontroller_name tableView:cellForRowAtIndexPath:]: 无法识别的选择器发送到实例 0x7b3a630&#39; - [viewcontroller_name tableView:cellForRowAtIndexPath:]: unrecognized selector sent to instance 0x7b3a630' Xcode 4.3.3-[__ NSArrayM length]:无法识别的选择器已发送到实例0x6b6dc60 - Xcode 4.3.3 -[__NSArrayM length]: unrecognized selector sent to instance 0x6b6dc60 解析json并获取异常,原因:&#39;-[__ NSCFArray objectForKey:]:无法识别的选择器已发送到实例0x7b1c7630 - parsing json and getting exception, reason: '-[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x7b1c7630 无法识别的选择器已发送到实例 - unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM