我已經創建了基於ipad應用的分割視圖,其中主視圖是表視圖,而細節視圖顯示圖像..我需要在橫向模式下顯示適合屏幕100%的圖像。 這可能是在按鈕事件或雙擊事件..我應該怎麼做。 在此先感謝。在分割視圖應用中隱藏主視圖..?
1
A
回答
4
通過在您的應用中使用包含分割視圖的主窗口頂部按需顯示的輔助窗口,您可以完成所需的任務。
創建一個新的UIWindow &一個新的UIViewController。將UIViewController的視圖添加到新窗口中,將窗口級別設置爲正值(1或更大),使其位於主窗口的頂部,然後將新窗口置於屏幕上。如果將窗口背景顏色設置爲[UIColor clearColor],並將圖像放置在新的UIViewController中的視圖中,則直接位於詳細視圖中的圖像頂部,那麼用戶將不會注意到任何新事件發生。然後,您可以將圖像幀動畫化爲全屏或做任何你想做的事情。我們有時會使用此技術來支持拖放或我們自己的自定義模式視圖控制器,但它也適用於您的目的。
下面是一個例子:
@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
相關問題
- 1. MVC局部視圖隱藏主視圖
- 2. 應用LayoutParams隱藏視圖
- 3. 在ConstraintLayout中隱藏從屬視圖時隱藏視圖
- 4. 視圖隱藏tabbarcontroller
- 5. Android CoordinatorLayout隱藏/疊加主視圖
- 6. 子視圖隱藏表視圖iphone
- 7. Tabbar作爲分割視圖控制器的主視圖(左側)
- 8. 在Android Studio中隱藏使用子視圖的卡片視圖
- 9. 隱藏超視圖而不隱藏其子視圖
- 10. 在iOS8中使用UISplitViewController隱藏主視圖控制器
- 11. 隱藏視圖並相應地重新定位其他視圖
- 12. 堆棧視圖隱藏了視圖,堆積在其中
- 13. 如何在Recycler視圖中隱藏廣告視圖
- 14. 在其他視圖的滾動中隱藏視圖
- 15. 在滾動視圖中隱藏文本視圖
- 16. 在iOS 10的堆棧視圖中隱藏視圖
- 17. 如何在Cocoa中顯示/隱藏第二個垂直分割視圖?
- 18. 在xcode中添加子視圖隱藏視圖的其餘部分
- 19. 如何在RecyclerView中隱藏視圖
- 20. 在根視圖中隱藏導航欄?
- 21. 在URL中隱藏視圖參數
- 22. 在不同視圖中隱藏UIButton?
- 23. 在畫面視圖中隱藏標題
- 24. 如何在UiSplitviewcontroller中隱藏iPad中的主視圖
- 25. neteans從視圖隱藏包
- 26. MBProgressHUD視圖不隱藏
- 27. openerp搜索視圖隱藏
- 28. 長時間隱藏視圖
- 29. UINavigationBar隱藏子視圖
- 30. Android視圖隱藏,拖動
我已經使用等作爲模態的視圖.. [自我presentModalViewController:自動畫:YES]; 但它的問題是,當我駁回彈出分割視圖只顯示根視圖不與細節視圖一起。 – Mahesh 2010-06-11 07:52:04