Arvis Arvis - 8 months ago 24
iOS Question

Select row only whent tapped on checkbox not on the row itself

Can't get that behaviour - row must become selected only by tapping on default checkbox in UITableView edit mode with multiple selection allowed.
When tapped on row elsewhere - row did not become selected but another details screen will open.

WORKOROUND (Xamarin C#):

// MyTableCell : UITableViewCell

public bool IsCheckBoxTapped;

public override void TouchesBegan(NSSet touches, UIEvent evt)
var touch = touches.FirstOrDefault() as UITouch;
var point = touch?.LocationInView(this) ?? new CGPoint();

var r = CGRect.FromLTRB(0, 0, 60, Frame.Height);
IsCheckBoxTapped = r.Contains(point);

base.TouchesBegan(touches, evt);


My recommendation is that you override the touches began method in a custom cell class in such a way that if the user touches the cell in the area that holds the checkbox, it will do something different than if they touch the area that does not hold the checkbox. Something similar to what I have below might work.

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    var point:CGPoint = CGPoint()

    if let touch = touches.first {
        point = touch.locationInView(self)

    if(checkBox.frame.contains(point)) {
        super.touchesBegan(touches, withEvent: event)
        //or however you would like to select the row
    else {
        //present your details screen