Problème de rotation sur le simulateur iOs

kef_hin

Membre confirmé
27 Mars 2008
29
0
Bonjour tout le monde :)

J'ai un petit problème de rotation sur le simulateur iOs, comme le montre l'image ci-dessous.

capturedecran20121220a1.png


Le problème n'est pas lié au simulateur puisque la rotation fonctionne toujours avec d'autres applications.

Les quatre "supported device orientations" sont sélectionnées. Je ne vois pas du tout d'où peut venir le problème. Au cas où, je vous mets le code ci-dessous.

Merci d'avance pour toute aide :rose:

AppDelegate.h
Bloc de code:
#import <UIKit/UIKit.h>
#import "MainViewController.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property MainViewController *mainViewController;

@end

AppDelegate.m
Bloc de code:
#import "AppDelegate.h"

@implementation AppDelegate

@synthesize window = _window;

@synthesize mainViewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    mainViewController = [[MainViewController alloc] init];
    [self.window setRootViewController:mainViewController];
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
}

- (void)applicationWillTerminate:(UIApplication *)application
{
}

@end

MainViewController.h
Bloc de code:
#import <UIKit/UIKit.h>
#import "CompaniesViewController.h"
#import "CashflowViewController.h"
#import "ScenarioViewController.h"

@interface MainViewController : UINavigationController

@property CompaniesViewController *companiesViewController;
@property CashflowViewController *cashflowViewController;
@property ScenarioViewController *scenarioViewController;

-(id)init;

-(void)companies_skipTapped;

-(void)applicationModeFlipperTapped:(id)button;

@end

MainViewController.m
Bloc de code:
#import "MainViewController.h"

@interface MainViewController ()

@end

@implementation MainViewController

@synthesize companiesViewController;
@synthesize cashflowViewController;
@synthesize scenarioViewController;

-(id)init {
    
    if (self = [super init]) {
        
        companiesViewController = [[CompaniesViewController alloc] init];
        cashflowViewController = [[CashflowViewController alloc] init];
        scenarioViewController = [[ScenarioViewController alloc] init];
        
    }
    
    return self;
    
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self pushViewController:companiesViewController animated:NO];
    	    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


-(void)companies_skipTapped {
    
    [self pushViewController:cashflowViewController animated:NO];
    
}

-(void)applicationModeFlipperTapped:(id)button {
    
    if ([button selectedSegmentIndex] == 0) {
        
        [self popViewControllerAnimated:NO];
        [self pushViewController:cashflowViewController animated:NO];
        [[cashflowViewController applicationModeFlipper] setSelectedSegmentIndex:0];
        
        
    } else if ([button selectedSegmentIndex] == 1) {
        
        [self popViewControllerAnimated:NO];
        [self pushViewController:scenarioViewController animated:NO];
        [[scenarioViewController applicationModeFlipper] setSelectedSegmentIndex:1];


        
    }
    
}

@end

CompaniesViewController.h
Bloc de code:
#import <UIKit/UIKit.h>

@interface CompaniesViewController : UIViewController

@end

CompaniesViewController.m
Bloc de code:
#import "CompaniesViewController.h"

@interface CompaniesViewController ()

@end

@implementation CompaniesViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	[self setTitle:@"Companies"];
    
    UIButton *hello = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [hello setTitle:@"skip" forState:UIControlStateNormal];
    [hello setFrame:CGRectMake(10, 10, 100, 37)];
    [hello addTarget:[self parentViewController] action:@selector(companies_skipTapped) forControlEvents:UIControlEventTouchUpInside];
    [[self view] addSubview:hello];
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

CashflowViewController.h
Bloc de code:
#import <UIKit/UIKit.h>
#import "CashflowTable.h"

@interface CashflowViewController : UIViewController

@property UISegmentedControl *applicationModeFlipper;

@property CashflowTable *cashflowTable;

@end

CashflowViewController.m
Bloc de code:
#import "CashflowViewController.h"

@interface CashflowViewController ()

@end

@implementation CashflowViewController

@synthesize applicationModeFlipper;

@synthesize cashflowTable;


- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self setTitle:@"Cashflow"];
    applicationModeFlipper = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc] initWithObjects:@"Cashflow",@"Scenario",nil]];
    [applicationModeFlipper setSegmentedControlStyle:UISegmentedControlStyleBar];
    [applicationModeFlipper setSelectedSegmentIndex:0];
    [applicationModeFlipper addTarget:[self parentViewController] action:@selector(applicationModeFlipperTapped:) forControlEvents:UIControlEventValueChanged];
    [[self navigationItem] setTitleView:applicationModeFlipper];
    
    cashflowTable = [[CashflowTable alloc] init];
    [[self view] addSubview:cashflowTable];
    
	
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

CashflowTable.h
Bloc de code:
#import <UIKit/UIKit.h>

@interface CashflowTable : UIView

@property CGRect pFrame;
@property CGRect lFrame;

-(id)init;

@end

CashflowTable.m
Bloc de code:
#import "CashflowTable.h"

@implementation CashflowTable

@synthesize pFrame;
@synthesize lFrame;

- (id)init {
    
    //[self setAutoresizingMask:(UIViewAutoresizingFlexibleWidth)];
    
    pFrame = CGRectMake(15, 15, 738, 637);
    lFrame = CGRectMake(15, 15, 994, 293);
    
    UIInterfaceOrientation io = [[UIApplication sharedApplication] statusBarOrientation];
    if (io == UIInterfaceOrientationPortrait 
    || io == UIInterfaceOrientationPortraitUpsideDown) {
        self = [super initWithFrame:pFrame];
    } else {
        self = [super initWithFrame:lFrame];
    }
    
    if (self) {
        
        
        [self setBackgroundColor:[UIColor purpleColor]];
        
        
    }
    return self;
    
}


@end

ScenarioViewController.h
Bloc de code:
#import <UIKit/UIKit.h>

@interface ScenarioViewController : UIViewController

@property UISegmentedControl *applicationModeFlipper;

@end

ScenarioViewController.m
Bloc de code:
#import "ScenarioViewController.h"

@interface ScenarioViewController ()

@end

@implementation ScenarioViewController

@synthesize applicationModeFlipper;

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self setTitle:@"Scenario"];
    applicationModeFlipper = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc] initWithObjects:@"Cashflow",@"Scenario",nil]];
    [applicationModeFlipper setSegmentedControlStyle:UISegmentedControlStyleBar];
    [applicationModeFlipper setSelectedSegmentIndex:1];
    [applicationModeFlipper addTarget:[self parentViewController] action:@selector(applicationModeFlipperTapped:) forControlEvents:UIControlEventValueChanged];
    [[self navigationItem] setTitleView:applicationModeFlipper];
    
    
    [[self view] setBackgroundColor:[UIColor greenColor]];


}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end