TTThumbView/TTPhotoView no autorotation

2019-05-13 06:31发布

In my app I try to use the TTphotoView, so in a ViewController I push the TTphotoView with my navigationController like this:



if(self.photoViewController == nil {

  PhotoViewController *viewController = [[PhotoViewController alloc] init];
  self.photoViewController = viewController;
  viewController.hidesBottomBarWhenPushed = YES;
  [viewController release];
}
[self.navigationController pushViewController:self.photoViewController animated:YES];
[self.navigationController  dismissModalViewControllerAnimated:YES]


the problem is when the user rotate the device on the PhotoViewController nothing happen.

EDIT : I can't believe people didn't have the same problem. If someone use the photoView in his application with his own navigation and not the TTNavigation can he tell me how did he push the ViewController?

3条回答
地球回转人心会变
2楼-- · 2019-05-13 07:10

Have you overridden your application's:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

and returned YES for the landscape orientations?

查看更多
Fickle 薄情
3楼-- · 2019-05-13 07:12

My comment for willcodejavaforfood, as I told you I can force by doing something like for example that but too many problem inside, and the PhotoViewController of three20 must do it by himself so I don't want that:



- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}


-(void) receivedRotate: (NSNotification *) notification {

     NSLog(@"ORIENTATION CHANGE");
     UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];

     if(interfaceOrientation == UIDeviceOrientationLandscapeRight) {

        [UIView beginAnimations:@"View Flip" context:nil];
        [UIView setAnimationDuration: 0.5f];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

        self.view.transform = CGAffineTransformIdentity;
        self.view.transform = CGAffineTransformMakeRotation(-M_PI/2);
        self.view.bounds = CGRectMake(0.0, 0.0, 480.0, 320.0);

        self.view.center = CGPointMake(240.0f, 160.0f);
        [UIView commitAnimations];

    }
}

查看更多
叛逆
4楼-- · 2019-05-13 07:24

I had the same problem.

I don't know why but TTScrollView deviceOrientationDidChange method in three20 code is commented out! If you uncomment it, it will work.

See the code here: http://github.com/facebook/three20/blob/master/src/TTScrollView.m

查看更多
登录 后发表回答