0
UIView *leftButtonItemView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];

UIImageView *addButtonEmptyImage = [[UIImageView alloc]init];
[addButtonEmptyImage setImage:[UIImage imageNamed:@"black.png"]];
addButtonEmptyImage.frame = CGRectMake(15,0,20,30);

[leftButtonItemView addSubview:addButtonEmptyImage];
[addButtonEmptyImage release];

UIImageView *correctButtonEmptyImage = [[UIImageView alloc]init];
[correctButtonEmptyImage setImage:[UIImage imageNamed:@"black.png"]];
correctButtonEmptyImage.frame = CGRectMake(50,0,20,30);

[leftButtonItemView addSubview:correctButtonEmptyImage];
[correctButtonEmptyImage release];

UIBarButtonItem *leftButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButtonItemView];
[leftButtonItemView release];

self.navigationItem.leftBarButtonItem = leftButtonItem;
[leftButtonItem release];

This is some source of my app. I know NavigationItem has two buttons(left and right). But I hope to make three buttons. so I make one button which use navigationItem and the other button which use a blank view. I want to click correctButtonEmptyImage. But this is in leftButtonItemView. namely, If I clicked the view which contains two images, I woud have seen leftButtonItemView not correctButtonEmptyImage. help me. thanks

1 Answer 1

1

Use UIButtons instead of UIImageViews as the subviews of your container view (leftButtonItemView). Use addTarget:action:forControlEvents: to assign action methods to the buttons.

PS: Please don't just say "It doesn't work" in your question. Tell us more specifically what works and what doesn't. Otherwise we won't be able to help you.

Sign up to request clarification or add additional context in comments.

1 Comment

Oh, Thanks. I'm so sorry about it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.