user77115
user77115

Reputation: 5577

How to test shouldAutorotateToInterfaceOrientation?

I have made it accessible by declaring it in the .h file of the controller,
but I don't like changing visibility of methods for test purposes only.

Is there any other way to call this method using Objective-C,
ex. by temporarily from the testclass changing accessibility of the method ?

Upvotes: 1

Views: 163

Answers (2)

meronix
meronix

Reputation: 6176

ok, as a reminder: the method is declared in apple class UIViewController.h

// Override to allow rotation. Default returns YES only for UIInterfaceOrientationPortrait
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;

so it's a public accessible method, and you don't need to declare it again in your subclass .h file

so, if you wanna call it directly for test, just do it (from any class that have a reference to an instance of your class):

BOOL rotating = [yourController shouldAutorotateToInterfaceOrientation:1]; 

Upvotes: 3

Krunal
Krunal

Reputation: 6490

This is override method, it get calls automatically, no need to call this method, or if still you want to try, then put debugger and test it.

Upvotes: 3

Related Questions