How can I insert 'info button' to UIToolBar ?
You should use 'UIBarButtonItem' to add some item to UIToolBar.
In example you can create it like below code.
UIBarButtonItem *actionItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:nil];
You can use UIBarButtonSystemItem* but there is no info button.
I noticed there is other init method named 'initWithCustomView'
You can create customized BarButtonItem with it.
I created info button with UIButton like below code.
UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoLight];
[button addTarget:self action:@selector(infoPressed:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] initWithCustomView:button];
Let's do it !! :)
Great! It's workign :) Thanks!
ReplyDeleteYou could also do:
ReplyDeleteUIButton *button = [UIButton buttonWithType:UIButtonTypeInfoLight];
UIBarButtonItem *infoButton = [[UIBarButtonItem alloc] initWithImage:button.currentImage style:UIBarButtonItemStylePlain target:self action:@selector(onSearchButtonPressed:)];
That way you will also get the "normal" bar button look...
That is definitely not how it's supposed to look...
Delete