【发布时间】:2013-08-19 12:56:24
【问题描述】:
我已将 ui 按钮添加到 disclouser 按钮
并实现了选择器方法
但是动作选择器没有响应按钮为什么和做什么
//To add a discloser button to show route map
UIButton *detailBtn=[UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.leftCalloutAccessoryView=detailBtn;
[detailBtn addTarget:self action:@selector(showRoute:) forControlEvents:UIControlEventTouchUpInside];
DisplayMap *ann=(DisplayMap *)annotation;
detailBtn.tag = ann.detailButtonTag;
UIButton *btnOnPopup=[[UIButton alloc] initWithFrame:CGRectMake(- 207, -6, 300, 43)];
btnOnPopup.backgroundColor = [UIColor whiteColor];
[btnOnPopup addTarget:self action:@selector(showRoute2:) forControlEvents:UIControlEventTouchUpInside];
btnOnPopup.tag = ann.detailButtonTag;
btnOnPopup.userInteractionEnabled = YES;
[detailBtn insertSubview:btnOnPopup aboveSubview:detailBtn];
选择器
[btnOnPopup addTarget:self action:@selector(showRoute2:) forControlEvents:UIControlEventTouchUpInside];
(第二个按钮 btnOnPopup)不起作用。
【问题讨论】:
-
其中有哪些不起作用?
-
第二个按钮 btnOnPopup
-
你能发布showRoute2吗:
-
为什么要添加按钮作为按钮的子视图?内置标注视图不支持大于约 32 像素的附件视图。 不相关的评论:我不建议使用按钮标签来识别注释,因为地图视图提供了更简单、优雅和可靠的方法来做到这一点。有关示例,请参阅 stackoverflow.com/questions/9876042/… 和 stackoverflow.com/questions/9462699/…。
-
保存在“btn”上的三个字母让你的代码阅读和讨论起来很痛苦。
标签: ios objective-c uibutton