我在旋转设备时遇到了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 Animation: PartialCurl ...bug during rotate?
我也有这个问题,一定程度上放弃了。然而,我向一位朋友提到了我的 困境,他鼓励我研究儿童VC的 逻辑,并回想一下我用于在父/子视图控制器之间传递数据的便利技巧。
在你的flipside视图控制器中,创建一个“rootViewController” 属性。在你父视图控制器,当你初始化 另一面视图控制器,可以设置(其中,“自我”是rootVC):
flipsideController.rootViewController = self;
然后,您可以使用此为您的另一面VC的 shouldAutorotateToInterfaceOrientation方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {return interfaceOrientation == self.rootViewController.interfaceOrientation;
}
Viola!翻转视图不再在部分旋转的父视图下旋转!
想必你从另一个VC中创建VC。你可以使用你喜欢的任何名称(rootViewController)在创建的VC中存储一个指向创建VC的指针,当你收到一个shouldAutorotateToInterfaceOrientation:call时,你检查旋转是否与创建VC相同。 要做到这一点,你需要为创建VC创建一个属性,像'@property(nonatomic,assign)UIViewController * rootViewController;'和相应的实例变量。 – Baglan