Jeanette Müller
Jeanette Müller

Reputation: 1009

iPhone: Rotate Scrollview inside UITableViewCell

i send the shouldAutorotateToInterfaceOrientation Funktion to the custom UITableViewCell where i created this function and so i want to rotate a scrollview inside this Cell.

But everything i tryed doesn't show any reaction.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.

if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
    NSLog(@"rotate cell");
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft){

        NSLog(@"left");
    }
    if (interfaceOrientation == UIInterfaceOrientationLandscapeRight){

        NSLog(@"right");
    }

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];

    // (180 * M_PI) / 180 == M_PI, so just use M_PI
    imagescroll.transform = CGAffineTransformMakeRotation(M_PI);

    [UIView commitAnimations];

    NSLog(@"rotation should start but doesnt");
}



return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

is there a need for rerendering the cell or something else?


sorry for the misunderstandings.

On the UITableViewController i override the shouldAutoRotate function and send a function call to all cells inside the table. The TableViewController is not allowed to rotate and sends from his own function just a NO back. But all of the Cells can do something and one of them should rotate its uiScrollView. The Call comes to the cell and the NSLog comes out with left or right based on my rotation. But the Scrollview doent do anything.

Upvotes: 0

Views: 343

Answers (2)

Roberto
Roberto

Reputation: 3839

The shouldAutorotateToInterfaceOrientation: method is not meant to do the actual rotation. This is not a method of UIView or UITableViewCell, but of UIViewController. Subclasses of UIViewController can override this method to indicate what orientations the current view controller supports.

Override that method in the view controller that you are using to display the table and return YES for supported orientations and the rotation will be done for you automatically. Then all you have to do is make sure you set the autoresizingMask of the views in your view controller to make sure they stretch or shrink accordingly.

If you are trying to achieve something else, please add more details as what you are trying to do. i.e. custom animation during an interface change, show different views or controls depending on the orientation, etc.

Upvotes: 1

Magic Bullet Dave
Magic Bullet Dave

Reputation: 9076

Can you explain a little more about what you are trying to achieve? It seems a little confused, shouldAutorotate method is overridden in the UIViewController to let the OS know what orientations are allowed. You then override the willAutorotate and didAutorotate methods to trap these specific actions. That said, most of this is unnecessary if you set the view properties correctly (i.e., your subViews will also rotate if the main view does).

If you add a little more detail as a comment, I'll update this answer with more relevant stuff.

Regards

Dave

Upvotes: 1

Related Questions