我想創建一個簡單的框架與一個可以自定義(選擇器明智和標題明智的)它的按鈕的筆尖。我做了以下:在我的框架中的NIB中訪問按鈕
我添加了一個屬性:
@property (nonatomic,retain) NSButton*accessoryButton;
,並將其連接到我的出口:
@synthesize accessoryButton = littleButton;
我然後共享的實例作爲這樣:
+ (TestWindow *)sharedPanel
{
return sharedPanel ? sharedPanel : [[[self alloc] init] autorelease];
}
- (id)init
{
if (sharedPanel) {
[self dealloc];
} else {
sharedPanel = [super init];
}
return sharedPanel;
}
並加載筆尖:
if(!somewindow)
{
[NSBundle loadNibNamed: @"window" owner:nil];
}
[NSApp activateIgnoringOtherApps:YES];
[somewindow center];
[somewindow setLevel:NSModalPanelWindowLevel];
[somewindow makeKeyAndOrderFront:self];
當我不過想標題,例如從我的樣本項目的變化,它永遠不會奏效。
[TestWindow sharedPanel] setTitle:@"hi"]; //doesnt work
這裏是我的setTitle:方法:
-(void)setTitle:(NSString *)buttonTitle
{
[[self accessoryButton] setTitle:buttonTitle];
[[self accessoryButton] display];
}
我沒有得到一個錯誤,但什麼也沒有發生任何。我錯過了什麼?
不要發送'[self dealloc]'。改爲發送'[self release]'。 – 2010-10-23 21:20:30
Thanks.Do you have any solutions for my question? :) – Pripyat 2010-10-23 22:07:48
沒有人有任何解決方案? :( – Pripyat 2010-10-24 20:35:50