これはObjective-Cに関連する質問ですので、明らかに多くのコードとサブクラスがあります。だからここに私の問題です。今、ボタンと2つのカラーUIViewをプログラムで作成するiPadアプリがあります。これらのカラーのUIViewはSubViewControllerによって制御され、全体がMainViewControllerによって制御されるUIViewにあります。 (すなわちMainViewController = [UIButton、SubViewController、SubViewController])Single Subview用ModalViewController
さて、このすべては、それが必要として起こる、と私は(下記)を期待するもので終わる:
しかし、ボタンをクリックすると、コンソールに「flipSubView1」と表示されますが、何も起こりません。モーダルビューは表示されず、エラーも発生しません。ただ何も。私が期待するのは、subView1またはビュー全体が水平に反転してsubView3を表示することです。私が見落としているいくつかのバグはあるのでしょうか?
viewtoolsAppDelegate.m
@implementation viewtoolsAppDelegate
@synthesize window = _window;
@synthesize mvc;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
mvc = [[MainViewController alloc] initWithFrame:self.window.frame];
[self.window addSubview:mvc.theView];
[self.window makeKeyAndVisible];
return YES;
}
MainViewController.m
@implementation MainViewController
@synthesize theView;
@synthesize subView1, subView2, subView3;
- (id)initWithFrame:(CGRect) frame
{
theView = [[UIView alloc] initWithFrame:frame];
CGRect sV1Rect = CGRectMake(frame.origin.x+44, frame.origin.y, frame.size.width-44, frame.size.height/2);
CGRect sV2Rect = CGRectMake(frame.origin.x+44, frame.origin.y+frame.size.height/2, frame.size.width-44, frame.size.height/2);
subView1 = [[SubViewController alloc] initWithFrame:sV1Rect andColor:[UIColor blueColor]];
subView2 = [[SubViewController alloc] initWithFrame:sV2Rect andColor:[UIColor greenColor]];
subView3 = [[SubViewController alloc] initWithFrame:sV1Rect andColor:[UIColor redColor]];
[theView addSubview:subView1.theView];
[theView addSubview:subView2.theView];
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[aButton addTarget:self action:@selector(flipSubView1:) forControlEvents:(UIControlEvents)UIControlEventTouchDown];
[aButton setFrame:CGRectMake(0, 0, 44, frame.size.height)];
[theView addSubview:aButton];
return self;
}
- (void)flipSubView1:(id) sender
{
NSLog(@"flipSubView1");
[subView3 setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[subView1 presentModalViewController:subView3 animated:YES];
}
SubViewController.m
@implementation SubViewController
@synthesize theView;
- (id)initWithFrame:(CGRect)frame andColor:(UIColor *)color
{
theView = [[UIView alloc] initWithFrame:frame];
theView.backgroundColor = color;
return self;
}
TLDR:モーダルビューが動作しません。フリップが見えるはずです。しないでください。
ここで、ViewをSubViewControllerのビューに設定していますか? – thomashw