mirror of
https://github.com/samsonjs/samhuri.net-ios.git
synced 2026-04-13 12:35:52 +00:00
fix bugs on the iPad
- wire up blogController properly - don’t crash trying to save non-existent posts
This commit is contained in:
parent
32829036ce
commit
dc25824cd3
2 changed files with 21 additions and 9 deletions
|
|
@ -21,7 +21,8 @@
|
|||
|
||||
@property (nonatomic, readonly, strong) BlogController *blogController;
|
||||
@property (nonatomic, readonly, strong) PostsViewController *postsViewController;
|
||||
@property (nonatomic, readonly, strong) EditorViewController *editorViewController;
|
||||
@property (nonatomic, readonly, strong) EditorViewController *editorViewControllerForPhone;
|
||||
@property (nonatomic, readonly, strong) EditorViewController *editorViewControllerForPad;
|
||||
|
||||
@end
|
||||
|
||||
|
|
@ -36,7 +37,8 @@
|
|||
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
|
||||
splitViewController.delegate = self;
|
||||
self.postsViewController.blogController = self.blogController;
|
||||
self.editorViewController.blogController = self.blogController;
|
||||
self.editorViewControllerForPhone.blogController = self.blogController;
|
||||
self.editorViewControllerForPad.blogController = self.blogController;
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
@ -69,15 +71,21 @@
|
|||
return postsViewController;
|
||||
}
|
||||
|
||||
- (EditorViewController *)editorViewController {
|
||||
- (EditorViewController *)editorViewControllerForPhone {
|
||||
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
|
||||
UINavigationController *navigationController = splitViewController.viewControllers.firstObject;
|
||||
if (navigationController.viewControllers.count > 1) {
|
||||
navigationController = navigationController.viewControllers.lastObject;
|
||||
EditorViewController *editorViewController = (EditorViewController *)navigationController.viewControllers.firstObject;
|
||||
return editorViewController;
|
||||
}
|
||||
return nil;
|
||||
EditorViewController *editorViewController = (EditorViewController *)navigationController.viewControllers.firstObject;
|
||||
return editorViewController;
|
||||
}
|
||||
|
||||
- (EditorViewController *)editorViewControllerForPad {
|
||||
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
|
||||
UINavigationController *navigationController = splitViewController.viewControllers.lastObject;
|
||||
EditorViewController *editorViewController = (EditorViewController *)navigationController.viewControllers.firstObject;
|
||||
return editorViewController;
|
||||
}
|
||||
|
||||
- (ModelStore *)newModelStoreWithPath:(NSString *)dbPath {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@
|
|||
|
||||
- (void)configureLinkView {
|
||||
NSURL *url = self.modifiedPost.url;
|
||||
if (self.post && url || [self pasteboardHasLink]) {
|
||||
if (self.post && (url || [self pasteboardHasLink])) {
|
||||
NSString *title = url ? url.absoluteString : @"Add Link from Pasteboard";
|
||||
[self.linkButton setTitle:title forState:UIControlStateNormal];
|
||||
self.removeLinkButton.hidden = !url;
|
||||
|
|
@ -190,7 +190,9 @@
|
|||
[notificationCenter removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
||||
[notificationCenter removeObserver:self name:DraftRemovedNotification object:nil];
|
||||
[notificationCenter removeObserver:self name:PublishedPostRemovedNotification object:nil];
|
||||
[self savePost];
|
||||
if (self.post) {
|
||||
[self savePost];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
|
|
@ -206,7 +208,9 @@
|
|||
#pragma mark - Notification handlers
|
||||
|
||||
- (void)applicationWillResignActive:(NSNotification *)note {
|
||||
[self savePost];
|
||||
if (self.post) {
|
||||
[self savePost];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)keyboardWillShow:(NSNotification *)note {
|
||||
|
|
|
|||
Loading…
Reference in a new issue