我从 UIWebView 获取触摸位置坐标并显示带有坐标的按钮。它与坐标匹配一起工作。所以,我需要增加按钮。我没有使用 Array 作为按钮。当我从 UIWebView 删除特定按钮时,它会删除所有按钮。我应该使用 NSMutableArray 吗?这里 x & y 是浮点值中的触摸点坐标
if(x && y){
NSLog(@"x is %f",x);
NSLog(@"y is %f",y);
button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button1 addTarget:self
action:@selector(click1:)
forControlEvents:UIControlEventTouchDown];
[button1 setTitle:@"click" forState:UIControlStateNormal];
button1.frame = CGRectMake(x, y, 30.0, 20.0);
// [btnArray addObject:button1];
button1.tag = gTag;
gTag++;
[wbCont.scrollView addSubview:button1];
}
删除按钮:
-(void)recycle:(id)sender{
for(int i=1;i<gTag;i++){
[[wbCont.scrollView viewWithTag:i] removeFromSuperview];
}