我正在使用JASidePanels UICollectionView update a single cell 这包括
Roundr_MainVC加载视图htis方式
//
// RoundrMD_MainVC.m
// Roundr
//
// Created by Robert Avram on 2015-04-19.
// Copyright (c) 2015 Robert Avram. All rights reserved.
//
#import "RoundrMD_MainVC.h"
#import "RoundsTableView_Rounds.h"
#import "JASidePanelController.h"
#import "RoundrMD_LeftMenu.h"
#
@interface RoundrMD_MainVC ()
@end
@implementation RoundrMD_MainVC
- (id)init {
if (self = [super init]) {
}
return self;
}
-(void) awakeFromNib
{
[self setLeftPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"LeftMenuView"]];
[self setCenterPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"CenterView"]];
self.bounceOnSidePanelClose = YES;
self.pushesSidePanels = NO;
}
@end
现在我可以与CENTER VIEW交互,使用这段代码呈现另一个ViewController,效果很好:
RND_Patient *doc = [_searchResults objectAtIndex:indexPath.row];
[self.searchController setActive:NO];
[self.tableView reloadData];
Roundr_PatientDetail *detailController = [[Roundr_PatientDetail alloc] initWithNibName:@"Roundr_PatientDetail" bundle:nil];
detailController.patient = doc;
self.editedIndexPath = indexPath;
detailController.delegate = self;
//detailController.status = 1;
self.animator = [[ZFModalTransitionAnimator alloc] initWithModalViewController:detailController];
self.animator.dragable = NO;
self.animator.bounces = YES;
self.animator.behindViewAlpha = 0.5f;
self.animator.behindViewScale = 0.5f;
self.animator.transitionDuration = 0.7f;
self.animator.direction = ZFModalTransitonDirectionBottom;
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
detailController.modalPresentationStyle = UIModalPresentationCustom;
detailController.transitioningDelegate = self.animator;
[self presentViewController:detailController animated:YES completion:nil];
问题是每当我与左侧菜单交互时,即使我重新加载与我最初加载的相同的CENTERVIEW控制器,我也无法与detailController交互,否则我会将消息发送到解除分配的实例(UINavigationController)。 / p>
//
// RoundrMD_LeftMenu.m
// Roundr
//
// Created by Robert Avram on 2015-04-22.
// Copyright (c) 2015 Robert Avram. All rights reserved.
//
#import "RoundrMD_LeftMenu.h"
#import "UIViewController+JASidePanel.h"
#import "RoundsWebViewController.h"
#import "RoundsAppDelegate.h"
#import <SVProgressHUD/SVProgressHUD.h>
#import <CWStatusBarNotification/CWStatusBarNotification.h>
#import "RND_PatientDB.h"
@interface RoundrMD_LeftMenu ()
@property (nonatomic, weak) UILabel *label;
@property (nonatomic, weak) UIButton *hide;
@property (nonatomic, weak) UIButton *show;
@property (nonatomic, weak) UIButton *removeRightPanel;
@property (nonatomic, weak) UIButton *addRightPanel;
@property (nonatomic, weak) UIButton *changeCenterPanel;
@end
@implementation RoundrMD_LeftMenu
- (void)viewDidLoad {
[super viewDidLoad];
self.crossImage.image = [self.crossImage.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.crossImage setTintColor:[UIColor redColor]];
self.checkImage.image = [self.checkImage.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.checkImage setTintColor:[UIColor greenColor]];
self.settingsImage.image = [self.settingsImage.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.settingsImage setTintColor:[UIColor lightGrayColor]];
self.printImage.image = [self.printImage.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.printImage setTintColor:[UIColor lightGrayColor]];
self.inboxImage.image = [self.inboxImage.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.inboxImage setTintColor:[UIColor lightGrayColor]];
self.betaFeedbackImage.image = [self.betaFeedbackImage.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.betaFeedbackImage setTintColor:[UIColor lightGrayColor]];
}
@synthesize PDFCreator;
#pragma mark - Button Actions
//- (void)_hideTapped:(id)sender {
// [self.sidePanelController setCenterPanelHidden:YES animated:YES duration:0.2f];
// self.hide.hidden = YES;
// self.show.hidden = NO;
//}
//
//- (void)_showTapped:(id)sender {
// [self.sidePanelController setCenterPanelHidden:NO animated:YES duration:0.2f];
// self.hide.hidden = NO;
// self.show.hidden = YES;
//}
//
//- (void)_removeRightPanelTapped:(id)sender {
// self.sidePanelController.rightPanel = nil;
// self.removeRightPanel.hidden = YES;
// self.addRightPanel.hidden = NO;
//}
- (IBAction)openSettings:(id)sender {
self.sidePanelController.centerPanel = [self.storyboard instantiateViewControllerWithIdentifier:@"Settings"];
}
- (IBAction)ActivePatientsTapped:(id)sender {
[self.sidePanelController setCenterPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"CenterView"]];
}
- (IBAction)DischargesTapped:(id)sender {
[self.sidePanelController setCenterPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"Archives"]];
}
- (IBAction)RoundedTapped:(id)sender {
[self.sidePanelController setCenterPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"Rounded"]];
}
- (IBAction)betaFeedback:(id)sender {
self.sidePanelController.centerPanel = [self.storyboard instantiateViewControllerWithIdentifier:@"showContactUs"];
}
-(IBAction)printAllPatients:(id)sender {
#pragma mark - modalViewController
[self.sidePanelController showCenterPanelAnimated:YES];
[self resignFirstResponder];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[SVProgressHUD show];
[self.view setUserInteractionEnabled:NO];
[queue addOperationWithBlock: ^{
RoundsAppDelegate *appDelegate = (RoundsAppDelegate *)[[UIApplication sharedApplication] delegate];
//decryptData and saveIt
NSString *htmlOfPatientData = [RND_PatientDB htmlRepresentation:appDelegate.patients];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
self.PDFCreator = [NDHTMLtoPDF createPDFWithHTML:htmlOfPatientData pathForPDF:[@"~/Documents/patientList.pdf" stringByExpandingTildeInPath] pageSize:kPaperSizeA4 margins:UIEdgeInsetsMake(10, 5, 10, 5) successBlock:^(NDHTMLtoPDF *htmlToPDF) {
NSData *pdfData = [NSData dataWithContentsOfFile:htmlToPDF.PDFpath];
[SVProgressHUD dismiss];
[SVProgressHUD showInfoWithStatus:@"Success"];
[self.view setUserInteractionEnabled:YES];
//Create an activity view controller with the profile as its activity item. APLProfile conforms to the UIActivityItemSource protocol.
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[NSLocalizedString(@"List_iMessage_Share", nil),pdfData] applicationActivities:nil];
NSArray *excludedActivities = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook,
UIActivityTypePostToWeibo,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo];
controller.excludedActivityTypes = excludedActivities;
[self presentViewController:controller animated:YES completion:nil];
[controller setCompletionWithItemsHandler:
^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
if (!completed){
CWStatusBarNotification *notification = [CWStatusBarNotification new];
[notification displayNotificationWithMessage:NSLocalizedString(@"Not_Share_PrintList", nil)
forDuration:3.0f];
notification.notificationLabelBackgroundColor = [UIColor colorWithRed:38.0f/255.0f green:81.0f/255.0f blue:123.0f/255.0f alpha:1.0f];
notification.notificationLabelTextColor = [UIColor whiteColor];
NSError *error;
[[NSFileManager defaultManager] removeItemAtPath:htmlToPDF.PDFpath error:&error];
}
else {
CWStatusBarNotification *notification = [CWStatusBarNotification new];
[notification displayNotificationWithMessage:NSLocalizedString(@"Did_Share_PrintList", nil)
forDuration:3.0f];
notification.notificationLabelBackgroundColor = [UIColor colorWithRed:38.0f/255.0f green:81.0f/255.0f blue:123.0f/255.0f alpha:1.0f];
notification.notificationLabelTextColor = [UIColor whiteColor];
NSError *error;
[[NSFileManager defaultManager] removeItemAtPath:htmlToPDF.PDFpath error:&error];
}
}];
} errorBlock:^(NDHTMLtoPDF *htmlToPDF) {
NSString *result = [NSString stringWithFormat:@"Failure (%@)", htmlToPDF];
[SVProgressHUD showInfoWithStatus:result];
}];
}];
}];
}
- (void)willMoveToParentViewController:(UIViewController *)parent {
[super willMoveToParentViewController:parent];
// NSLog(@"%@ willMoveToParentViewController %@", self, parent);
}
- (void)didMoveToParentViewController:(UIViewController *)parent {
[super didMoveToParentViewController:parent];
// NSLog(@"%@ didMoveToParentViewController %@", self, parent);
}
@end
我相信作为UiNavigationController的CENTERVIEW在从左侧菜单加载它的过程中被取消分配,然后我使用对其UINavigationController有强引用的presentViewController,但是这个navigationController被释放,因此它崩溃。
谢谢