由于解除分配的实例导致应用程序崩溃

时间:2013-11-13 08:30:45

标签: ios

我有两个屏幕,一个用于登录: 类名是LoginViewController。屏幕截图为enter image description here

它包含两个文本字段:用户名和密码。

点击忘记密码:此屏幕打开此屏幕的类是ForgotPasswordViewController enter image description here

点击DOB文本字段时,会出现一个日期选择器选择器,从中选择日期。现在,如果按下后退按钮,则会出现登录屏幕。一切都很好,直到现在。现在,如果我点击用户或密码文本字段,则应用程序崩溃将记录此日志

2013-11-13 13:55:53.582 mRx [4684:60b] *** - [ForgotPasswordViewController respondsToSelector:]:发送到解除分配的实例0x15d7b510的消息

我不知道造成这次崩溃的原因。请提出一些建议来处理它。我已经有2天了,但仍然没有找到解决方案。如果您需要任何其他相关信息,请发表评论。

错误跟踪的屏幕截图如下:enter image description here

请帮忙

带来日期选择器的文本字段的代码是:

       #pragma mark - TextField Delegate Methods

- (void)textFieldDidBeginEditing:(UITextField *)textField {     self.txt_currentFocussedTextField = textField;     [[AppDelegate sharedInstance] addToolbarForKeyboard:textField];

if (textField == self.txt_DOB) {
    [textField resignFirstResponder];
    _actionSheetPicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeDate selectedDate:self.selectedDate minimumDate:Nil maximumDate:Nil target:self action:@selector(dateWasSelected:element:) origin:textField];
    self.actionSheetPicker.hideCancel = NO;
    [self.actionSheetPicker showActionSheetPicker];

}

}

.h文件中的代码是:

      #import <UIKit/UIKit.h>
    #import "AbstractActionSheetPicker.h"

   @interface ForgotPasswordViewController : UIViewController<UITextFieldDelegate>

     @property (strong,nonatomic) UITextField * txt_currentFocussedTextField;
     @property (strong,nonatomic) IBOutlet UITextField *txt_username;
     //@property (weak,nonatomic) IBOutlet UITextField *txt_lastname;
     @property (strong,nonatomic) IBOutlet UITextField *txt_DOB;
     @property (strong,nonatomic) IBOutlet UITextField *txt_phone;
     @property (strong,nonatomic)  IBOutlet UITextField * txt_zip;
     @property (strong,nonatomic) IBOutlet UITextField * txt_newPassword;


     @property (strong,nonatomic) IBOutlet UIButton *btn_save;

      @property (strong,nonatomic) IBOutlet UIScrollView * scrollview;

      @property (nonatomic, strong) AbstractActionSheetPicker *actionSheetPicker;
      @property (nonatomic, retain) NSDate *selectedDate;

    - (void)forgotPasswordRequest;

      @end

1 个答案:

答案 0 :(得分:0)

看起来你的ForgotPasswordViewController正在观察一个NSNotification,也许是UIKeyboardWillShowNotification,当你从导航堆栈中弹出时,你没有从NSNotificationCenter中删除它作为观察者。 问题是通知中心尝试通知您已经解除分配的视图控制器。  在- (void)removeObserver:(id)observer name:(NSString *)aName object:(id)anObjectviewDidDisappear:中使用dealloc

相关问题