Hiding a Bar button item in the view

Posted by devb0yax on Stack Overflow See other posts from Stack Overflow or by devb0yax
Published on 2010-06-15T09:41:24Z Indexed on 2010/06/15 9:52 UTC
Read the original article Hit count: 254

Filed under:

How can you able to hide the (done) bar button item in a view? Basically, I have a view controller added with navigation bar (in IB) then, I also added a bar button item into the nav bar. I just want initially the (done) bar button item is hidden.. when input is in the text view the (done) button is already visible.

Any idea on this implementation on a view controller?

Here's my sample code:

@interface MyTextViewViewController : UIViewController <UITextViewDelegate> 
{
 UITextView *m_textView;
 UIBarButtonItem *doneBarButtonItem;   
}

@property(nonatomic,retain) IBOutlet UITextView *m_textView;
@property(nonatomic,retain) IBOutlet UIBarButtonItem *doneBarButtonItem;

- (IBAction)saveAction:(id)sender;

.m file:

- (void)viewDidLoad {
    [super viewDidLoad];
    doneBarButtonItem.hidden = YES;   --> compile error!!!
}

- (void)textViewDidBeginEditing:(UITextView *)textView
{ 
    doneBarButtonItem.hidden = NO;   --> compile error!!!
}

- (IBAction)saveAction:(id)sender
{
    doneBarButtonItem.hidden = YES;   --> compile error!!!
    ...
}

© Stack Overflow or respective owner

Related posts about iphone