lor
lor

Reputation: 15

Toolbar and Navigationbar bad Animation

What i would like to do is to rotate at landscape mode and leave the toolbar and navigation bar at ( vertical to the right for the toolbar and vertical to the left for the navigation bar), but only rotating the view and the icons on the toolbar and navigation bar.. What i have done so far is using the willAnimateSecondHalfofRotation.When going to landscapemode the position is what i wanted but i can see the transition from rotating and it looks bad.What i am trying to do is something like the camera of the iphone when only the icons of the toolbar are being rotating...

Could you help me? Thanks in advanced. Lor

Upvotes: 1

Views: 257

Answers (1)

Can Berk Güder
Can Berk Güder

Reputation: 113310

  1. Disable auto-rotation:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    
  2. Register for UIDeviceOrientationDidChange notifications:

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
    
  3. Respond to device orientation changes:

    - (void)orientationChanged:(NSNotification *)notification {
        // Adjust views according to [[UIDevice currentDevice] orientation];
    }
    
  4. Don't forget to unregister

    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    

Upvotes: 1

Related Questions