Сообщение отправлено на освобожденный экземпляр

Я использую JASidePanels UICollectionView обновить одну ячейку Это состоит из

  • Roundr_MainVC: JASidePanelController: представление, которое имеет левое меню и активный вид на центр
  • Roundr_LeftMenu: левое меню приложения
  • CenterView: UINavigationController. Активный вид справа.

Roundr_MainVC загружает представление таким образом

 //
//  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).

   //
//  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

Вот NSzombies

Я полагаю, что CENTERVIEW, который является UiNavigationController, освобождается в процессе, загружая его из левого меню, и затем я использую presentViewController, который имеет сильную ссылку на его UINavigationController, однако этот навигационный контроллер освобождается, и поэтому происходит сбой.

Спасибо

0 ответов

Другие вопросы по тегам