這個問題已被問了很多次,但我試過每個解決方案,他們都沒有解決我的問題。iphone如何禁用UIBarButtonItem
下面是工具欄創建代碼:
- (id)initWithBlogArticle:(BlogArticle *)theArticle
{
if (self = [super init])
{
CustomToolbar* tools = [[CustomToolbar alloc] initWithFrame:CGRectMake(0, 0, 90, 48.01)];
[tools setTintColor:[UIColor colorWithRed:0.62 green:0.70 blue:0.13 alpha:1.0]];
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];
UIBarButtonItem* previousArticle = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind
target:self
action:@selector(displayPreviousArticle)];
[previousArticle setStyle:UIBarButtonItemStyleBordered];
[buttons addObject:previousArticle];
[previousArticle release];
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil
action:nil];
[buttons addObject:spacer];
[spacer release];
UIBarButtonItem *nextArticle = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward
target:self
action:@selector(displayNextArticle)];
[nextArticle setStyle:UIBarButtonItemStyleBordered];
[buttons addObject:nextArticle];
[nextArticle release];
[tools setItems:buttons animated:NO];
[buttons release];
[[self navigationItem] setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithCustomView:tools] autorelease]];
[tools release];
[self setWebView:[[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]];
[[self webView] setDelegate:self];
[self loadBlogArticle:theArticle];
[self setView:[self webView]];
}
return self;
}
我試圖用setEnabled:NO來無微不至,它永遠不會奏效,這是推動我瘋狂的禁用按鈕應該是這麼簡單..所以要麼做起來非常複雜,要麼我不瞭解非常基本的東西。
請幫助,在此先感謝。
應該setEnabled:NO來,我嘗試在模擬器上,它的工作。 你在哪裏禁用按鈕? – arkchong 2011-06-10 09:35:02
你有沒有試過這個:UIBarButtonItemName.enabled = NO; – 2011-06-10 09:30:30