我在旋轉設備時遇到了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