iDevelopper / PBRevealViewController

A UIViewController subclass for revealing a left and/or right view controller above or below a main view controller.
MIT License
80 stars 16 forks source link

Request : full tvOS compatibility #23

Closed Sebacho-Barajas closed 7 years ago

Sebacho-Barajas commented 7 years ago

i got it to work on my tvOS app , I used #if TARGET_OS_IOS for tvOS prohibited iOS properties , but It would be great if you added full support for tvOS , I'm sure many users would love to use this library on their tvOS apps , we could use the tv remote button 'Menu' to show and hide the RevealView.

screen shot 2017-02-10 at 4 46 00 pm

iDevelopper commented 7 years ago

Yes, good idea! Why use the TV Remote Menu Button to reveal/hide side view instead of gesture or button on screen? And if you have left and right side views?

Sebacho-Barajas commented 7 years ago

you are right , i had to disable tap gesture because when I tap on the table cell it used to hide the menu, I had to use pan gesture to hide the menu.

iDevelopper commented 7 years ago

Yes tap gesture is on the focus on tvOS. We'll see that, it's a good idea.

Sebacho-Barajas commented 7 years ago

was testing pan gesture and it doesn't work once you are on the side menu, to dismiss it i have to select the cell

iDevelopper commented 7 years ago

I did some tests. It seems that the menu (left side) should be opened if there is no left focus remaining in the main view. But if there is no focus left, methods shouldUpdateFocusInContext and didUpdateFocusInContext are not called. This is an example that opens the menu with the Menu button on the remote control and if the menu is open, the Menu button returns to the system. So I turned off the tap and pan for the TV! If you have any ideas, welcome ???

PBRevealTVOS.zip

Sebacho-Barajas commented 7 years ago

i tested it with a UITapGestureRecognizer , it worked fine and the Menu Button didn't return to the system.

- (void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer *tapGestureRec = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    tapGestureRec.allowedPressTypes = @[@(UIPressTypeMenu)];
    [self.view addGestureRecognizer:tapGestureRec];
}

- (void)handleTap:(UITapGestureRecognizer *)recognizer {
    if (self.isLeftViewOpen) {
        [self revealLeftView];
    } else {
        [self revealLeftView];
    }
}

we should add a tap gesture in the controller just for tvOS

if TARGET_OS_TV

//menu tap

endif

I was thinking about adding a property in the Delegate to change which view you want to show with siri remote control, by default it will be added to left view

Sebacho-Barajas commented 7 years ago

I added the menu Tap inside the controller for tvOS Target check my code : PBRevealViewController tvOS.zip

iDevelopper commented 7 years ago

I know we can do that but this is not allowed by Apple:

2017-02-14_07-25-53

iDevelopper commented 7 years ago

Do you know an application with a left side menu on tvOS? In general, they use top shelf.

Sebacho-Barajas commented 7 years ago

you're right , and what if we use another gesture for that? play/pause button or open menu with menu and close it with play/pause or swipe gesture

iDevelopper commented 7 years ago

In my sample, you can show left menu if you press menu button and if left menu is open, if you press again menu button, the Apple tv home screen is shown. Is it not ok?

Sebacho-Barajas commented 7 years ago

yes it works , what do you think about adding the UITapGestureRecognizer but with another button ?

iDevelopper commented 7 years ago

I tried to reproduce the same behavior as the top shelf. I added two invisibles button for opening left and right view. For example, for the left view call [self tvOSLeftRevealButton]; This will create an invisible button and It will open the left view when it is focused by swiping. Also added swipe gesture recognizer to hide them. And the press menu button functionality for opening the left view and again to return to home screen. And using focus environment protocol methods to update the focus. What about this?

PBRevealTVOS 2.zip

Sebacho-Barajas commented 7 years ago

thanks I will test it and give you a feedback!

iDevelopper commented 7 years ago

Ok. Can we continue this discussion via our email addresses? Mine is patrick.bodet4@wanadoo.fr

iDevelopper commented 7 years ago

Rather, test this one. It is a better project with corrected bugs.

PBRevealTVOS 3.zip

Sebacho-Barajas commented 7 years ago

great, yes we can continue via our email mine is sebasbarajasc@gmail.com

Sebacho-Barajas commented 7 years ago

just tested it and it works perfectly!