Arvis Arvis - 1 year ago 74
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);

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download