我有一个导航控制器,已将其添加UIButton
到导航栏,但它有问题。即使我在按钮之外点击,它仍然称之为动作。
这就是我创建和添加按钮的方式:
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[backBtn setImage:[UIImage imageNamed:@"btn_back.png"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(backPressed:) forControlEvents:UIControlEventTouchUpInside];
[backBtn setFrame:CGRectMake(0, 0, 70, 30)];
//[backBtn setFrame:CGRectMake(20, 7, 70, 30)];
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:backBtn] autorelease];
这是按钮的点击范围: