0

iOS 4.1用のXcode 4.3.2でIphoneアプリケーションを開発しています

IB から UIView に UIButton を追加し、IBAction に接続しました。しかし、ボタンをタッチすると、EXC_BAD_ACCESSエラーが発生しました。

プロジェクトの作成時に ARC を有効にしました。

このエラーとグーグルの後、メモリ管理が悪いとこのエラーが発生することがわかりました。しかし、この問題の原因を特定できませんでした。どうすれば問題を見つけることができますか?

.h ファイルに含まれるもの

-(IBAction)openTwitterSignInViewController:(id)sender;

.m ファイルに含まれるもの

- (void)openTwitterSignInViewController:(id)sender{
    UIViewController *secondViewController = [[TwitterSignInViewController alloc] initWithNibName:@"TwitterSignInViewController" bundle:nil];
    [self.navigationController pushViewController:secondViewController animated:YES]; 
}

またUIButtonopenTwitterSignInViewControllerIB経由で接続されています。

コンソール出力がありません。理由はわかりません。だから私はスクリーンショットを追加しています。 ここに画像の説明を入力

LoginViewController.m

#import "LoginViewController.h"
#import "Helper.h"
#import "TwitterSignInViewController.h"

@interface LoginViewController ()

@end

@implementation LoginViewController
@synthesize topBarText, userNameText, passwordText, passwordReminderButton, loginButton;
@synthesize signInTwitterButton, registerButton;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 15, 20)];

    userNameText.leftView = paddingView;
    userNameText.leftViewMode = UITextFieldViewModeAlways;

    passwordText.leftView = [NSKeyedUnarchiver unarchiveObjectWithData:
                             [NSKeyedArchiver archivedDataWithRootObject: paddingView]];
    passwordText.leftViewMode = UITextFieldViewModeAlways;

    topBarText.font = [UIFont fontWithName:@"Neo Sans Pro" size:14 ];
    userNameText.font = [UIFont fontWithName:@"Neo Sans Pro" size:14];

    passwordText.font = [UIFont fontWithName:@"Neo Sans Pro" size:14];
    passwordReminderButton.titleLabel.font = [UIFont fontWithName:@"Neo Sans Pro" size:14];
    loginButton.titleLabel.font = [UIFont fontWithName:@"Neo Sans Pro" size:14];

    registerButton.titleLabel.font = [UIFont fontWithName:@"Neo Sans Pro" size:14];
}

- (IBAction)openTwitterSignInViewController:(id)sender{
    TwitterSignInViewController *secondViewController = [[TwitterSignInViewController alloc] initWithNibName:@"TwitterSignInViewController" bundle:nil];
    [self.navigationController pushViewController:secondViewController animated:YES]; 
}
- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

少なくとも、Zombie Objects を有効にしてコンソール出力を取得しました。これが出力です。しかし、私はまだエラーを見つけることができませんでした

2012-08-01 21:11:30.569 adMingle[3156:f803] *** -[LoginViewController performSelector:withObject:withObject:]: message sent to deallocated instance 0x6857420
4

3 に答える 3

0

この回答のように問題を解決しました。メインビューコントローラーにプロパティを追加し、割り当ててから呼び出しましたpushViewController

于 2012-08-01T18:34:12.957 に答える
0

この LoginViewController を表示している場所からビューコントローラーにコードを投稿できますか? この問題は、どこかからオブジェクトが過剰にリリースされているためです。

于 2012-08-01T18:34:21.917 に答える
0

.m ファイルでも IBAction を宣言します。メソッド名はどこでも同じにする必要があります。

-(IBAction)openTwitterSignInViewController:(id)sender;
于 2012-08-01T13:05:10.890 に答える