0

尝试切换视图时(减去将数据添加到属性的两行,它可以正常工作。但是使用 2 行(即这两行):

self.firstViewData = fvc;

firstViewData.passedData = @"hello test test test";

它崩溃说:

2013-05-29 16:40:43.864 测试 [16166:907]由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UITabBarController setPassedData:]:无法识别的选择器发送到实例 0x325620” *

全段:

过滤器视图控制器.h

@interface FilterViewController : UIViewController
{
    FirstViewController *firstViewData;
}

@property (nonatomic, retain) FirstViewController *firstViewData;

过滤视图控制器.m

@synthesize firstViewData;

- (IBAction)backToMap:(id)sender {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    FirstViewController *fvc = [storyboard instantiateViewControllerWithIdentifier:@"TabBarController"];
    fvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    self.firstViewData = fvc;

    firstViewData.passedData = @"hello test test test";

    [self presentViewController:fvc animated:YES completion:nil];
}

第一视图控制器.h

@interface FirstViewController : UIViewController
{
    NSString *passedData;
}

@property(nonatomic, retain) NSString *passedData;

第一视图控制器.m

@synthesize passedData;
NSLog(@"result: %@", passedData);
4

1 回答 1

2

您的fvc变量是 a UITabBarController,而不是 a FirstViewController。看看你是怎么设置fvc的。

于 2013-05-29T15:52:18.680 回答