This question is quite similar to https://segmentfault.com/q/1010000004486783/a-1020000004487227. I moved my answer here:
Add the shouldAutorotate method in ViewController. The logic inside is roughly as follows:
@implementation ViewController
- (BOOL)shouldAutorotate {
int32_t i = 1;
if (i == 1) {
return NO;
}
return YES;
}
@end
If your ViewController is managed in UINavigationController, you need to modify the corresponding behavior of UINavigationController. For example, the implementation idea through Category is roughly as follows:
#import "UINavigationController.h"
@implementation UINavigationController (Overrides)
- (BOOL)shouldAutorotate {
id currentViewController = self.topViewController;
if ([currentViewController isKindOfClass:[<#your-vc#> class]]) {
int32_t i = 1;
if (i == 1) {
return NO;
}
return YES;
}
return YES;
}
@end
This question is quite similar to https://segmentfault.com/q/1010000004486783/a-1020000004487227. I moved my answer here:
Add the
shouldAutorotate
method in ViewController. The logic inside is roughly as follows:If your ViewController is managed in UINavigationController, you need to modify the corresponding behavior of UINavigationController. For example, the implementation idea through Category is roughly as follows:
See if this helps you: http://www.tekuba.net/program/306/