无法使用 viewWithTag 访问 NSSearchField
我正在我的 appcontroller.m 类中创建搜索字段,并将其作为子视图添加到 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];
}
,fullBrowserView 被 [pAppController fullBrowserView] 调用,但我的 NSSearchField 没有重置为零值。
注意:fullBrowserView 是 IBOutlet 并在 Xib 文件(Interface Builder)中创建,
可能是什么问题。请帮忙。
I am creating the searchfield in my appcontroller.m class and adding it as subview to BrowserView in awakeFromNib
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;
}
When I am trying to accessing this searchfield from a different nsview sub class
-(BOOL)becomeFirstResponder {
appController *pAppController = [[appController alloc] init];
//[pIKBController testMethod];
NSSearchField *mySearchFieldTemp =(NSSearchField *) [[pAppController fullBrowserView] viewWithTag:2];
[mySearchFieldTemp setStringValue:@""];
[pAppController release];
return [super becomeFirstResponder];
}
fullBrowserView is getting called with [pAppController fullBrowserView],but my NSSearchField is not resetting to nil value.
Note : fullBrowserView is IBOutlet and created in the Xib file(Interface Builder)
What might be the problem.Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论