【发布时间】:2018-04-16 06:56:41
【问题描述】:
我的图片不是点击表
-(void)makeBlockAction{
blocksArr = [NSMutableArray new];
}
我的事件功能是
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch* myTouch = [[touches allObjects] objectAtIndex:0];
NSLog(@"test2");
if ( [ blocksArr containsObject: myTouch.view ])
{
myTouch.view.alpha = 0;
NSLog(@"test");
}
}
【问题讨论】:
-
User Interaction是否启用? -
-(void)makeBlockAction{ CGPoint newCen = CGPointMake(xCen, yCen); CGRect blockFrame = CGRectMake(0, 0, blockWidth, blockWidth); UIImageView* block= [[UIImageView alloc] initWithFrame:blockFrame]; NSString* imgName = [NSString stringWithFormat:@"unr1.png"]; block.image= [UIImage imageNamed:imgName]; block.center = newCen; block.userInteractionEnabled = YES; [blocksArr addObject: 块]; [_gameView addSubview:block]; xCen += 块宽度; }
标签: ios objective-c uiimage