
HI,
Can anyone provide me the code for uibarbuttonitem initwithcustomview action? In my application I am adding custom BarButtonItem, how I can attach an action to it?
Thanks

Hi,
Use the following code:
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
myButton.frame = CGRectMake(0, 0, 60,30);
[myButton setImage:[UIImage imageNamed:@"myimage.png"]
forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(myButtonAction:)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *aBar = [[UIBarButtonItem alloc] initWithCustomView:myButton];
[myButton release];
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.