当我旋转设备时我遇到了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 逻辑和我回忆起一个方便的技巧,我曾经用它来传递数据 父/子视图控制器。
在您的侧视图控制器中,创建一个“rootViewController” 属性。在父视图控制器中,初始化时 翻转视图控制器,你设置(其中“self”是rootVC):
flipsideController.rootViewController = self;
然后你将它用于你的翻转VC shouldAutorotateToInterfaceOrientation方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {return interfaceOrientation == self.rootViewController.interfaceOrientation;
}
中提琴!翻转视图不再在部分下方旋转 卷起父母的观点!
答案 0 :(得分:1)
@From post:在您的侧视图控制器中,创建一个“rootViewController”属性。
#import <UIKit/UIKit.h>
@class ModalViewExampleViewController;
@interface flipSideViewController : UIViewController {
ModalViewExampleViewController *rootViewController;
}
@property (nonatomic, retain) ModalViewExampleViewController *rootViewController;
@end
并在您的flipSideViewController的实现文件中
#import "ModalViewExampleViewController.h"
@synthesize rootViewController;