вот что я пытаюсь достичь, было бы направить действия на вращении устройства ...Отправить Действие на вращении прошивки устройства
точки я имею 360 игрока, Я хотел бы, чтобы видео запускалось только после того, как устройство находится на пейзаже. Если на портрете я хочу отобразить сообщение, произнесите «поворот устройства в альбомной ориентации», а когда пользователь повернет устройство, воспроизведение видео.
ниже мой код до сих пор:
- (IBAction)test:(id)sender forEvent:(UIEvent *)event {
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation ]== UIDeviceOrientationLandscapeRight)
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"demo1" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:path];
Video360ViewController *videoController = [[Video360ViewController alloc] initWithNibName:@"HTY360PlayerVC" bundle:nil url:url];
[videoController VRMode:true];
if (![[self presentedViewController] isBeingDismissed]) {
[self presentViewController:videoController animated:YES completion:nil];
}
}
if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)
{
NSLog(@"UIDeviceOrientationPortrait");
}
}
Проблема этого кода, чем срабатывают только на TouchUp Внутри в Sent Event. , , во всяком случае, чтобы действие начиналось с вращения?
Спасибо за вашу помощь!
EDIT ---
TRYIED СЛЕДУЮЩИЙ Aswell:
- (IBAction)test:(id)sender forEvent:(UIEvent *)event {
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation ]== UIDeviceOrientationLandscapeRight)
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"demo1" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:path];
Video360ViewController *videoController = [[Video360ViewController alloc] initWithNibName:@"HTY360PlayerVC" bundle:nil url:url];
[videoController VRMode:true];
if (![[self presentedViewController] isBeingDismissed]) {
[self presentViewController:videoController animated:YES completion:nil];
}
}
if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)
{
NSLog(@"UIDeviceOrientationPortrait");
}
}
Кому это следует добавить? под первой линией IBAction? – tibewww
включите этот метод в класс ура – vaibby
Хм, я не понимаю, я только начинаю в iOS Dev. Я отредактировал вопрос с добавлением кода, который вы сказали, но он покажет мне ошибку «USe on undercalified identifier shouldautorotatetointerfaceorientation» Любая идея? Спасибо за вашу помощь, очень ценю – tibewww