It is because by default an instance of UIView has tag equal to 0. Therefore in line
tempButton = (UIButton*)[self.view viewWithTag:self.selectedPath.row];
you get one of the many subviews with tag 0 (your button is among them, but apparently some other view is returned, causing a crash). Set tags as index.row + 1 instead and it should work fine.