objective c - How to add an image to UIBarButtonItem? -



objective c - How to add an image to UIBarButtonItem? -

i created custom button , applied uibarbuttonitem. there no error nil shown on navigation bar:( code-

//create custom button uiimage *image = [uiimage imagenamed:@"testbutton.png"]; uibutton *mycustombutton = [uibutton buttonwithtype:uibuttontypecustom]; mycustombutton.bounds = cgrectmake( 0, 0, image.size.width, image.size.height ); [mycustombutton setimage:image forstate:uicontrolstatenormal]; [mycustombutton addtarget:nil action:@selector(goback:) forcontrolevents:uicontroleventtouchupinside]; uibarbuttonitem *button = [[uibarbuttonitem alloc] initwithcustomview:mycustombutton]; self.navigationitem.leftbarbuttonitem = button; self.navigationcontroller.navigationbar.barstyle = uibarstyledefault; [button release]; [mycustombutton release]; [image release]; [navid release];

anybody can prepare code? :)

from the docs:

initwithimage:style:target:action:

try that.

objective-c ios uibarbuttonitem navigationbar

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -