7

以下代码是从情节提要向当前视图添加子视图:

EventSearchViewController* view1 = [self.storyboard instantiateViewControllerWithIdentifier:@"searchView"];

[view1 setBookingSystem:system];

[self.view addSubview:view1.view];

在视图“view1”中,有一个 textField。以下是文本字段的 IBAction,事件是“退出时结束”。

-(IBAction)searchKeyword:(id *)sender
{
    NSLog(@"searchKeyword");
}

以下是错误信息。

2012-05-26 20:26:47.369 OnlineBooking[6607:f803]-[__NSCFType searchKeyword:]:无法识别的选择器发送到实例 0x6d8eb80

2012-05-26 20:26:47.369 OnlineBooking[6607:f803] * WebKit 在 webView 中丢弃了一个未捕获的异常:shouldInsertText:replacingDOMRange:givenAction: delegate: -[__NSCFType searchKeyword:]: 无法识别的选择器发送到实例 0x6d8eb80

4

2 回答 2

12

EventSearchViewController如果您使用 ARC,则需要保留您的,或强烈引用它。如果将其分配view1为局部变量,则在调用时将不再存在searchKeyword:。(错误表明它的内存已被释放并重新用于不同类型的对象。)

于 2012-05-26T12:59:08.570 回答
0

对我来说,问题是我从来没有打电话

- (void)removeTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents

在我打电话之前

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents

再次。

于 2013-09-04T20:09:36.983 回答