iOS-imageViewのbutton応答クリックイベントを実現する方法
1357 ワード
/**
imageview , button ;
: imageview.userInterfaceEnabled = YES
*/
eg:-
-(void)setUI
{
int column = COLUMN;
int gap = ( self.view.frame.size.width - column * yellowViewWidth ) / (column +1);
if ( gap <= 0) {
NSLog(@"Column is too big!");
return;
}
for (int i = 0; i < self.arrayDate.count ; i++) {
//add yellowView and set x y width hight and attribute
int x = i % column ;
int y = i / column;
CGFloat yellowX = ( x + 1 ) * gap + x * yellowViewWidth;
CGFloat yellowY = ( y + 1 ) * gap + y * yellowViewHight;
MyView *yellowView = [[MyView alloc] initWithFrame:CGRectMake(yellowX, yellowY, yellowViewWidth, yellowViewHight)];
MyModel *model = self.arrayDate[i];
// yellowView appModel
yellowView.model = model;
//NSLog(@"-========= %@",self.arrayDate[i]);
/**
imageview , button ;
: imageview.userInterfaceEnabled = YES
*/
yellowView.userInteractionEnabled = YES;
[self.view addSubview:yellowView];
}
}
:https://www.cnblogs.com/yangsanchao/p/5014476.html