Помоги мне понять ответ - PullRequest
0 голосов
/ 21 сентября 2011

У меня проблема с UIModalTransitionStylePartialCurl, когда я поворачиваю устройство, потому что завиток не вращается, как я ожидал, и я нашел приведенную ниже выдержку из ответа, но не могу понять.

Я не уверен, как создать свойство "rootviewcontroller", как указано ниже

Так что я жду вашего совета, чтобы продолжить. Я действительно застрял с этим на долгие дни...

Спасибо за любую помощь: -


КОД ИСТОЧНИКА, КОТОРЫЙ Я ИМЕЮ

//
//  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: PartialCurl... ошибка при повороте?

У меня тоже была эта проблема, и я немного сдался.Тем не менее, я упомянул свою дилемму другу, который посоветовал мне изучить логику дочернего ВК, и я вспомнил удобный трюк, который я использовал для передачи данных между контроллерами родительского / дочернего представления.

В вашем оборотепросмотреть контроллер, создать свойство «rootViewController».В вашем родительском контроллере представления, когда вы инициализируете контроллер представления сальто, вы устанавливаете (где «self» - rootVC):

flipsideController.rootViewController = self;

Затем вы используете это для метода mustAutorotateToInterfaceOrientation вашего виртуального контроллера flipside:

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

}

Виола!Обратная сторона больше не вращается под частично свернутой родительской панорамой!

1 Ответ

1 голос
/ 21 сентября 2011

@ Из сообщения: Создайте свойство rootViewController в своем контроллере flipside.

#import <UIKit/UIKit.h>

@class ModalViewExampleViewController;

@interface flipSideViewController : UIViewController {

    ModalViewExampleViewController *rootViewController;

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

@end

и в файле реализации вашего flipSideViewController

#import "ModalViewExampleViewController.h"

@synthesize rootViewController;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...