在拆分视图应用程序中隐藏主视图..? [英] Hiding master view in split view app..?

查看:63
本文介绍了在拆分视图应用程序中隐藏主视图..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了基于拆分视图的ipad应用程序,其中主视图是表格视图,而详细信息视图显示图像..我需要在横向模式下显示适合屏幕100%的图像。
这可能是按钮事件或双击事件..我应该怎么做。
提前致谢。

I have created split view based ipad app, where master view is table view while Detail view display images.. I need to display the image fit to screen 100% in landscape mode. This could be on button event or double tap event.. How should i do that. Thanks in advance.

推荐答案

您可以使用应用程序中的辅助窗口完成您想要的操作,该辅助窗口在您的主要按需显示包含拆分视图的窗口。

You can accomplish what you want by using a secondary window in your app that you display on-demand on top of your main window that contains the split view.

创建一个新的UIWindow&一个新的UIViewController。将UIViewController的视图添加到新窗口,将窗口级别设置为正值(1或更多),使其位于主窗口的顶部,然后将新窗口设置在屏幕上。如果将窗口背景颜色设置为[UIColor clearColor]并将图像放置在新UIViewController内的视图中,则直接在详细视图中的图像顶部,则用户将不会注意到任何新的事件发生。然后,您可以将图像框架设置为全屏幕或根据需要执行任何操作。我们有时会使用这种技术来支持阻力和阻力。放弃或我们自己的自定义模态视图控制器,但它也适用于您的目的。

Create a new UIWindow & a new UIViewController. Add the UIViewController's view to your new window, set the window level to a positive value (1 or more) so that it is on top of your main window, then put the new window onscreen. If you set the window background color to [UIColor clearColor] and position your image in a view inside the new UIViewController directly on top of the image that is in the detail view then the user won't notice that anything new has happened. You can then animate the image frame up to fullscreen or do whatever you want. We sometimes use this technique to support drag & drop or our own custom modal view controllers but it'll work for your purpose too.

这是一个例子:

@interface MyViewController : UIViewController @end


@interface AppDelegate : NSObject <UIApplicationDelegate> {
    MyViewController            *overlayController;
    UIWindow                    *overlayWindow;

    UIWindow                    *window;                // the main window that contains your splitview
    UINavigationController      *navigationController;  // or split view contoller, whatever, your main controller
}

@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic, retain) IBOutlet UIWindow *window;

@end


@implementation MyViewController

- (void) loadView {
    self.view = [[[UIView alloc] initWithFrame: CGRectZero] autorelease];
    self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    self.view.backgroundColor = [UIColor redColor];
}

@end


@implementation AppDelegate

@synthesize window, navigationController;


- (void) click:(id) sender {
    [overlayController.view removeFromSuperview];
    [overlayController release];
    overlayController = nil;

    overlayWindow.hidden = YES;
    [overlayWindow release];
    overlayWindow = nil;
}


- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    // Add the navigation controller's view to the window and display.
    // standard stuff...
    [self.window addSubview: navigationController.view];
    [self.window makeKeyAndVisible];

    // add the overlay window
    // note that both the overlay window and controller are retained until we dismiss
    // the window, this is important!
    overlayWindow = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].applicationFrame];   // or [UIScreen mainScreen].bounds, depending on what you want
    overlayController = [MyViewController new];
    overlayController.view.frame = overlayWindow.bounds;

    UIButton *button = [UIButton buttonWithType: UIButtonTypeRoundedRect];

    [button addTarget: self action: @selector(click:) forControlEvents: UIControlEventTouchUpInside];
    [button setTitle: @"Done" forState: UIControlStateNormal];
    button.frame = CGRectMake( 0, 0, 100, 50 );
    button.center = overlayController.view.center;

    [overlayController.view addSubview: button];

    // the controller's view is the first and only view in the
    // new window.  this ensures you get rotation events.  Add any subviews
    // that will appear in the new window to overlayContoller.view
    [overlayWindow addSubview: overlayController.view];
    [overlayWindow setWindowLevel: 1];
    [overlayWindow makeKeyAndVisible];

    return YES;
}


- (void)dealloc {
    [overlayController release];
    [overlayWindow release];
    [navigationController release];
    [window release];
    [super dealloc];
}


@end

这篇关于在拆分视图应用程序中隐藏主视图..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆