开发者

Can TTImageView has click event?

开发者 https://www.devze.com 2023-04-06 09:17 出处:网络
I subclassed TTTableMessageItem to show user response, and I want to add click event on user avatar image (I knew it is a TTImage开发者_JAVA百科View in TTTableMessageItemCell). How to ?I work it out a

I subclassed TTTableMessageItem to show user response, and I want to add click event on user avatar image (I knew it is a TTImage开发者_JAVA百科View in TTTableMessageItemCell). How to ?


I work it out as below:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [touches anyObject];

    if ([touch view] == myImageView)
    {
        // do process
    }

}


You may find it easier to simple add a gesture recogniser to the view - touchesBegan is certainly acceptable, but gesture recognisers are somewhat simpler and probably more suited to a tap detection event.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号