ios - UICollectionViewCell which contains a UILabel and UIButton not recognizing touches on half the cell -


I've added the UILLunch and UIButton for a UICollectionViewCell, but when I touch / tap the cell it only registers my tap on the left. Do not pay attention to any touch or null on the right half of the half-cell cell? I should also note that it does not matter how long the text is in UILabel.

Example text:

  @ "short text" @ "too long text  

in the text above," text "touch where the final" t "in.

CODE:

  - (id) initWithFrame: (CGRect) frame {self = [super initWithFrame: frame]; if (self) {self.clipsToBounds = yes; MyLabel = [[UILabel alloc] initWithFrame: self.bounds]; MyLabel.frame = UIEdgeInsetsInsetRect (myLabel.frame, UIEdgeInsetsMake (0, SEARCH_CELL_PADDING, 0, SEARCH_CELL_PADDING +30)); MyLabel .textAlignment = NSTextAlignmentLeft; MyLabel.autoresizingMask = UIViewAutoresizingFlexibleHyight | UIViewAutoresizingFlexibleWidth; MyLabel.font = RECENT_SEARCH_CELL_FONT; MyLabel.textcolor = WK_COLOR_GRAY_77; MyButton = [[UIButton alloc] initWithFrame: CGRectMake (0, 0, sv.b Nd. Size.width, 30)]; MyButton.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; UIImage * btnImage = [UIImage imageNamed: @ "icon2.png"]; [MyButton setImage: btnImage forState: UIControlStateNormal]; UIImage * btn Selected Image = [UIImage imageNamed: @ "icon.png"]; [MyButton setImage: BTN Selected Image for State: UIContolstadt]; [MyButton setUserInteractionEnabled: NO]; [Self-added sublueview: myton]; [Self add sbueview: mylabel]; } Healthy return; }  

Maybe it's in the UIOOLQPUSE setup in the cell or offset?

Update:

I added the following code and never called the tap method.

  UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget: self action: @ selector (Lebltap)]; [_RENSENSCHEELLABEL ADSTECHERCAZOZIZER: TAP GESTURE];  

I have also changed the following code to:

  - (id) initWithFrame: (CGRect) frame {self = [super initWithFrame: frame ]; If (self) {self.clipsToBounds = yes; MyLabel = [[UILabel alloc] initWithFrame: self.bounds]; MyLabel.frame = UIEdgeInsetsInsetRect (myLabel.frame, UIEdgeInsetsMake (0, SEARCH_CELL_PADDING, 0, SEARCH_CELL_PADDING +30)); MyLabel.textAlignment = NSTextAlignmentLeft; MyLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; MyLabel.font = RECENT_SEARCH_CELL_FONT; MyLabel.textcolor = WK_COLOR_GRAY_77; MyButton = [[UIButton alloc] initWithFrame: CGRectMake (0, 0, selfbound.ize.width, 30)]; MyButton.autoresizingMask = UIViewAutoresizingFlexibleHyight | UIViewAutoresizingFlexibleWidth; UIImage * btnImage = [UIImage imageNamed: @ "icon2.png"]; [MyButton setImage: btnImage forState: UIControlStateNormal]; UIImage * btn Selected Image = [UIImage imageNamed: @ "icon.png"]; [MyButton setImage: BTN Selected Image for State: UIContolstadt]; [MyButton setUserInteractionEnabled: Yes]; [Self add sbueview: mylabel]; [Self-added sublueview: myton]; } Healthy return;  

No work

< P> Replace the above code: [self-adjusting: myButton]; [Self add sbueview: myLabel];

with: [self add sbueview: myLabel]; [Self-aid SUBWOOView: Mayton];

Since you are adding buttons to look at as a subview, then that label has been added as a subview that can overlap with the position of the button. So first add "label" as a subview and "button" now the action will now take action

Hope this will solve your problem. Cheers :)


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -