MCR
MCR

Reputation: 1643

UITableView didSelectRowAtIndexPath Not Selected on UIPageViewController

I have a UIViewController that has UIPageViewController's view added to it. That UIPageViewController has a page with a subview that has a UITableView added as a subview. I am using iOS 6 and the method didSelectRowAtIndexPath is not being called when I click on the cell. There is a weird "bug" though... If I turn the page halfway and then come back to the page I was on (without completing the page turn), I'm then able to select the cell. I assume this has something to do with gesture recognizers, but I can't figure it out. I tried removing the gesture recognizers from the instantiation of the UIPageViewController, but was unable to get that to work.

I remove the tap gesture recognizers from the UIPageViewController like so, but still the buggy behavior exists...

for (UIGestureRecognizer *recognizer in pageViewController.gestureRecognizers) {
    if ([recognizer isKindOfClass:[UITapGestureRecognizer class]]) {
        recognizer.enabled = NO;
    }
}

Any suggestions?

Upvotes: 2

Views: 706

Answers (2)

MCR
MCR

Reputation: 1643

It turned out to be something very simple. On my UIViewController I had the autoresizingMask set to FlexibleHeight. Changing it to None for some reason fixed my problem.

// self.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

// Changed to :

 self.contentView.autoresizingMask = UIViewAutoresizingNone;

If anyone can shed some light onto the reasons why this is the case, I'd appreciate it.

Upvotes: 0

Shamsudheen TK
Shamsudheen TK

Reputation: 31311

Subclass UIView with UITableView. let say myUIView.

Implement the UITableView delegates in myUIView.

Add myUIView as a subview of UIPageControl.

UITableView delegates in myUIView will trigger.

Upvotes: 0

Related Questions