我在appcontroller.m类中创建了searchfield,并将其作为子视图添加到awakeFromNib中的BrowserView
mysearchField = [ [ NSSearchField alloc ] initWithFrame: NSMakeRect(10 , 50.0, 225.0, 35.0) ];
[mysearchField setTag:2];
[[mysearchField cell] setPlaceholderString:@"Page Number & Press Enter"];
[BrowserView addSubview: mysearchField ];
[mysearchField release];
-(NSView *)fullBrowserView
{
NSLog(@"fullBrowserView called");
return fullBrowserView;
}
当我尝试从不同的nsview子类
访问此搜索字段时-(BOOL)becomeFirstResponder {
appController *pAppController = [[appController alloc] init];
//[pIKBController testMethod];
NSSearchField *mySearchFieldTemp =(NSSearchField *) [[pAppController fullBrowserView] viewWithTag:2];
[mySearchFieldTemp setStringValue:@""];
[pAppController release];
return [super becomeFirstResponder];
}
使用[pAppController fullBrowserView]调用fullBrowserView,但我的NSSearchField没有重置为nil值。
注意:fullBrowserView是IBOutlet并在Xib文件(Interface Builder)中创建
可能是什么问题。请帮忙。