简体   繁体   中英

Help me to understand the answer given

I have problem with UIModalTransitionStylePartialCurl when i rotate the device beacuse the curl is not rotating as i expected and i found the below extract of the answer but i am not able to undertsand.

i am not sure how to create a "rootviewcontroller" Property as told like below

So i am looking for your guidence to proceed further .I am really stuck with this thing for long days...

Thanks for any help:-


The SOURCE CODE I HAVE

//
//  ModalViewExampleViewController.h
//  ModalViewExample
//
//  Created by Tim Neill on 11/09/10.
//

#import <UIKit/UIKit.h>

@interface ModalViewExampleViewController : UIViewController {
    UIButton *showDefaultButton, *showFlipButton, *showDissolveButton, *showCurlButton;
}

@property (nonatomic, retain) IBOutlet UIButton *showDefaultButton, *showFlipButton, *showDissolveButton, *showCurlButton;

- (IBAction)showDefault:(id)sender;
- (IBAction)showFlip:(id)sender;
- (IBAction)showDissolve:(id)sender;
- (IBAction)showCurl:(id)sender; 

@end 

//
//  ModalViewExampleViewController.m
//  ModalViewExample
//
//  Created by Tim Neill on 11/09/10.
//

#import "ModalViewExampleViewController.h"
#import "SampleViewController.h"

@implementation ModalViewExampleViewController

@synthesize showDefaultButton, showFlipButton, showDissolveButton, showCurlButton;

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

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

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

- (IBAction)showDefault:(id)sender {
    SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
    [self presentModalViewController:sampleView animated:YES];
}

- (IBAction)showFlip:(id)sender {
    SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
    [sampleView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self presentModalViewController:sampleView animated:YES];
}

- (IBAction)showDissolve:(id)sender {
    SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
    [sampleView setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
    [self presentModalViewController:sampleView animated:YES];
}

- (IBAction)showCurl:(id)sender {
    SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
    sampleView.rootViewController = self;

    [sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
    [self presentModalViewController:sampleView animated:YES];
} 

- (void)dealloc {
    [showDefaultButton release];
    [showFlipButton release];
    [showDissolveButton release];
    [showCurlButton release];
    [super dealloc];
}
@end

//
//  SampleViewController.h
//  ModalViewExample
//
//  Created by Tim Neill on 11/09/10.
//

#import <UIKit/UIKit.h>

@class RootViewController;

@interface SampleViewController : UIViewController {

    RootViewController *rootViewController;

    UIButton *dismissViewButton;
}

@property (nonatomic, retain) IBOutlet UIButton *dismissViewButton;

@property (nonatomic, retain) RootViewController *rootViewController;


- (IBAction)dismissView:(id)sender;

@end 

//
//  SampleViewController.m
//  ModalViewExample
//
//  Created by Tim Neill on 11/09/10.
//

#import "SampleViewController.h"


@implementation SampleViewController

@synthesize rootViewController;

@synthesize dismissViewButton;

- (IBAction)dismissView:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}

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

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


- (void)dealloc {
    [dismissViewButton release];
    [super dealloc];
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     [self dismissModalViewControllerAnimated:YES];
    return YES;
} 
@end

UIView Animation: PartialCurl ...bug during rotate?

I too had this issue and somewhat gave up. However, I mentioned my dilemma to a friend, who encouraged me to look into the child VC's logic and I recalled a handy trick that I've used to pass data between parent/child view controllers.

In your flipside view controller, create a "rootViewController" property. In your parent view controller, when you initialize the flipside view controller, you set (where "self" is the rootVC):

 flipsideController.rootViewController = self; 

You then use this for your flipside VC's shouldAutorotateToInterfaceOrientation method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return interfaceOrientation == self.rootViewController.interfaceOrientation;

}

Viola! The flipside view no longer rotates underneath the partially curled up parent view!

@From the post : In your flipside view controller, create a "rootViewController" property.

#import <UIKit/UIKit.h>

@class ModalViewExampleViewController;

@interface flipSideViewController : UIViewController {

    ModalViewExampleViewController *rootViewController;

}
@property (nonatomic, retain) ModalViewExampleViewController *rootViewController;

@end

and in your flipSideViewController's implementation file

#import "ModalViewExampleViewController.h"

@synthesize rootViewController;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM