adding in popover and moving hide logic for story detail view

This commit is contained in:
Roy Yang 2012-06-11 12:25:38 -07:00
parent b954441caa
commit 8a7fb0966a
7 changed files with 72 additions and 52 deletions

View file

@ -132,20 +132,6 @@
[super viewDidAppear:animated]; [super viewDidAppear:animated];
} }
- (void)viewWillDisappear:(BOOL)animated {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
NSArray *subviews = [[appDelegate.detailViewController.view subviews] copy];
for (UIView *subview in subviews) {
if (subview.tag == 12) {
[subview removeFromSuperview];
}
}
[subviews release];
}
}
- (void)dealloc { - (void)dealloc {
[storyTitlesTable release]; [storyTitlesTable release];
[feedViewToolbar release]; [feedViewToolbar release];

View file

@ -20,7 +20,7 @@
@interface NewsBlurAppDelegate : BaseViewController <UIApplicationDelegate> { @interface NewsBlurAppDelegate : BaseViewController <UIApplicationDelegate> {
UIWindow *window; UIWindow *window;
UISplitViewController *splitViewController; UISplitViewController *splitStoryController;
UINavigationController *navigationController; UINavigationController *navigationController;
NewsBlurViewController *feedsViewController; NewsBlurViewController *feedsViewController;
FeedDetailViewController *feedDetailViewController; FeedDetailViewController *feedDetailViewController;
@ -56,7 +56,7 @@
} }
@property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UISplitViewController *splitViewController; @property (nonatomic, retain) IBOutlet UISplitViewController *splitStoryController;
@property (nonatomic, readonly, retain) IBOutlet UINavigationController *navigationController; @property (nonatomic, readonly, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic, retain) IBOutlet NewsBlurViewController *feedsViewController; @property (nonatomic, retain) IBOutlet NewsBlurViewController *feedsViewController;
@property (nonatomic, retain) IBOutlet FeedDetailViewController *feedDetailViewController; @property (nonatomic, retain) IBOutlet FeedDetailViewController *feedDetailViewController;

View file

@ -23,7 +23,7 @@
@synthesize window; @synthesize window;
@synthesize splitViewController; @synthesize splitStoryController;
@synthesize navigationController; @synthesize navigationController;
@synthesize feedsViewController; @synthesize feedsViewController;
@synthesize feedDetailViewController; @synthesize feedDetailViewController;
@ -67,11 +67,14 @@
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
navigationController.viewControllers = [NSArray arrayWithObject:feedsViewController]; navigationController.viewControllers = [NSArray arrayWithObject:feedsViewController];
[window addSubview:splitViewController.view]; [window addSubview:splitStoryController.view];
splitViewController.viewControllers = [NSArray arrayWithObjects:navigationController, detailViewController, nil]; splitStoryController.viewControllers = [NSArray arrayWithObjects:navigationController, detailViewController, nil];
[window addSubview:splitViewController.view]; [window addSubview:splitStoryController.view];
splitStoryController.delegate = (id)detailViewController;
self.window.rootViewController = self.splitViewController;
} else { } else {

View file

@ -8,6 +8,7 @@
#import "NewsBlurViewController.h" #import "NewsBlurViewController.h"
#import "NewsBlurAppDelegate.h" #import "NewsBlurAppDelegate.h"
#import "DetailViewController.h"
#import "FeedTableCell.h" #import "FeedTableCell.h"
#import "ASIHTTPRequest.h" #import "ASIHTTPRequest.h"
#import "PullToRefreshView.h" #import "PullToRefreshView.h"
@ -105,6 +106,20 @@
[self.feedTitlesTable selectRowAtIndexPath:[feedTitlesTable indexPathForSelectedRow] [self.feedTitlesTable selectRowAtIndexPath:[feedTitlesTable indexPathForSelectedRow]
animated:YES scrollPosition:UITableViewScrollPositionMiddle]; animated:YES scrollPosition:UITableViewScrollPositionMiddle];
// remove the right detail view in storySplitController
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
NSArray *subviews = [[appDelegate.detailViewController.view subviews] copy];
for (UIView *subview in subviews) {
if (subview.tag == 12) {
[subview removeFromSuperview];
}
}
[subviews release];
}
} }
- (void)viewDidAppear:(BOOL)animated { - (void)viewDidAppear:(BOOL)animated {

View file

@ -10,8 +10,11 @@
@class NewsBlurAppDelegate; @class NewsBlurAppDelegate;
@interface DetailViewController : UIViewController { @interface DetailViewController : UIViewController <UISplitViewControllerDelegate> {
NewsBlurAppDelegate *appDelegate; NewsBlurAppDelegate *appDelegate;
} }
@property (strong, nonatomic) UIPopoverController *masterPopoverController;
@end @end

View file

@ -9,11 +9,8 @@
#import "DetailViewController.h" #import "DetailViewController.h"
#import "NewsBlurAppDelegate.h" #import "NewsBlurAppDelegate.h"
@interface DetailViewController ()
@end
@implementation DetailViewController @implementation DetailViewController
@synthesize masterPopoverController = _masterPopoverController;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{ {
@ -43,20 +40,35 @@
} }
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
NSArray *subviews = [[self.view subviews] copy]; // NSArray *subviews = [[self.view subviews] copy];
for (UIView *subview in subviews) { // for (UIView *subview in subviews) {
if (subview.tag == 12) { // if (subview.tag == 12) {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { // if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
NSLog(@"portrait"); // NSLog(@"portrait");
subview.frame = CGRectMake(0,44,768,960); // subview.frame = CGRectMake(0,44,768,960);
} else { // } else {
NSLog(@"landscape"); // NSLog(@"landscape");
subview.frame = CGRectMake(0,44,704,704); // subview.frame = CGRectMake(0,44,704,704);
} // }
} // }
} // }
//
} }
@end #pragma mark - Split view
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
// barButtonItem.title = NSLocalizedString(@"Master", @"Master");
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = popoverController;
}
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
// Called when the view is shown again in the split view, invalidating the button and popover controller.
// [self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil;
}
@end

View file

@ -126,6 +126,7 @@
<string key="NSFrameSize">{768, 1024}</string> <string key="NSFrameSize">{768, 1024}</string>
<reference key="NSSuperview"/> <reference key="NSSuperview"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<object class="NSColor" key="IBUIBackgroundColor"> <object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int> <int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes> <bytes key="NSRGB">MSAxIDEAA</bytes>
@ -283,14 +284,6 @@
</object> </object>
<int key="connectionID">45</int> <int key="connectionID">45</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">splitViewController</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="159036857"/>
</object>
<int key="connectionID">141</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection"> <object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">detailViewController</string> <string key="label">detailViewController</string>
@ -299,6 +292,14 @@
</object> </object>
<int key="connectionID">142</int> <int key="connectionID">142</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">splitStoryController</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="159036857"/>
</object>
<int key="connectionID">143</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection"> <object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">appDelegate</string> <string key="label">appDelegate</string>
@ -598,7 +599,7 @@
<reference key="dict.values" ref="0"/> <reference key="dict.values" ref="0"/>
</object> </object>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">142</int> <int key="maxID">143</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions"> <object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -1216,7 +1217,7 @@
<string>moveSiteViewController</string> <string>moveSiteViewController</string>
<string>navigationController</string> <string>navigationController</string>
<string>originalStoryViewController</string> <string>originalStoryViewController</string>
<string>splitViewController</string> <string>splitStoryController</string>
<string>storyDetailViewController</string> <string>storyDetailViewController</string>
<string>window</string> <string>window</string>
</object> </object>
@ -1247,7 +1248,7 @@
<string>moveSiteViewController</string> <string>moveSiteViewController</string>
<string>navigationController</string> <string>navigationController</string>
<string>originalStoryViewController</string> <string>originalStoryViewController</string>
<string>splitViewController</string> <string>splitStoryController</string>
<string>storyDetailViewController</string> <string>storyDetailViewController</string>
<string>window</string> <string>window</string>
</object> </object>
@ -1286,7 +1287,7 @@
<string key="candidateClassName">OriginalStoryViewController</string> <string key="candidateClassName">OriginalStoryViewController</string>
</object> </object>
<object class="IBToOneOutletInfo"> <object class="IBToOneOutletInfo">
<string key="name">splitViewController</string> <string key="name">splitStoryController</string>
<string key="candidateClassName">UISplitViewController</string> <string key="candidateClassName">UISplitViewController</string>
</object> </object>
<object class="IBToOneOutletInfo"> <object class="IBToOneOutletInfo">