2012-02-23 11 views
0

「Touch Up Inside」でUIButtonをタッチするたびに、アプリケーションがEXC_BAD_ACCESSでクラッシュする2回目です。私は問題を見つけられず、すべてが問題ないと思う。ここで2回目のタッチ後にUIButton EXC_BAD_ACCESS?

は私の.hファイルである:

#import <UIKit/UIKit.h> 

@interface AnleitungWebViewController : UIViewController { 

    UIWebView *anleitungwebview; 
    NSURL *pdfpfad_anleitung; 
    NSString *aktuellesBild; 
    NSString *nummer; 
    IBOutlet UIActivityIndicatorView *indicator; 
    IBOutlet UILabel *laden; 
    IBOutlet UIButton *vor; 
} 

@property (nonatomic, retain) IBOutlet UIWebView *anleitungwebview; 
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *indicator; 
@property (nonatomic, retain) IBOutlet UILabel *laden; 
@property (nonatomic, retain) IBOutlet UIButton *vor; 
@property (nonatomic, retain) NSURL *pdfpfad_anleitung; 
@property (nonatomic, retain) NSString *aktuellesBild; 
@property (nonatomic, retain) NSString *nummer; 

- (IBAction)zuruck:(id)sender; 
- (IBAction)vor:(id)sender; 


@end 

そして、私の.mファイル:アイデアと

#import "AnleitungWebViewController.h" 

@implementation AnleitungWebViewController 

@synthesize anleitungwebview, pdfpfad_anleitung, indicator, laden, aktuellesBild, nummer, vor; 

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

- (void)didReceiveMemoryWarning 
{ 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view from its nib. 
    //NSURLRequest *request = [[NSURLRequest alloc] initWithURL:pdfpfad_anleitung]; 
    //[anleitungwebview loadRequest:request]; 

    //aktuellesBild = @"anl_30148_120701-de-001"; 

    NSString *path = [[NSBundle mainBundle] pathForResource:aktuellesBild ofType:@"jpg"]; 
    NSURL *url = [NSURL URLWithString:path]; 

    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; 
    [anleitungwebview loadRequest:request]; 
} 

- (void)webViewDidStartLoad:(UIWebView *) webView { 

    [indicator startAnimating]; 
    indicator.hidden = NO; 
    laden.hidden = NO; 

} 

- (void)webViewDidFinishLoad:(UIWebView *) webView { 

    [indicator stopAnimating]; 
    indicator.hidden = YES; 
    laden.hidden = YES; 

} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

- (IBAction)zuruck:(id)sender { 

    nummer = [aktuellesBild substringFromIndex:[aktuellesBild length]-3]; 

    int num = [nummer intValue]; 
    num = num - 1; 

    if (num < 10) { 
     nummer = @"00"; 
     nummer = [nummer stringByAppendingString:[NSString stringWithFormat:@"%d", num]]; 
    } 
    else if (num > 9) { 
     nummer = @"0"; 
     nummer = [nummer stringByAppendingString:[NSString stringWithFormat:@"%d", num]]; 
    } 
    else{ 
     nummer = [nummer stringByAppendingString:[NSString stringWithFormat:@"%d", num]]; 
    } 

    aktuellesBild = [aktuellesBild substringToIndex:[aktuellesBild length]-3]; 
    aktuellesBild = [aktuellesBild stringByAppendingString:nummer]; 

    NSString *path = [[NSBundle mainBundle] pathForResource:aktuellesBild ofType:@"jpg"]; 
    NSURL *url = [NSURL URLWithString:path]; 

    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; 
    [anleitungwebview loadRequest:request]; 

    NSLog(@"%@", aktuellesBild); 
} 

- (IBAction)vor:(id)sender { 

    NSLog(@"TEST"); 

    nummer = [aktuellesBild substringFromIndex:[aktuellesBild length]-3]; 

    int num = [nummer intValue]; 
    num = num + 1; 

    if (num < 10) { 
     nummer = @"00"; 
     nummer = [nummer stringByAppendingString:[NSString stringWithFormat:@"%d", num]]; 
    } 
    else if (num > 9) { 
     nummer = @"0"; 
     nummer = [nummer stringByAppendingString:[NSString stringWithFormat:@"%d", num]]; 
    } 
    else{ 
     nummer = [nummer stringByAppendingString:[NSString stringWithFormat:@"%d", num]]; 
    } 

    aktuellesBild = [aktuellesBild substringToIndex:[aktuellesBild length]-3]; 
    aktuellesBild = [aktuellesBild stringByAppendingString:nummer]; 

    NSString *path = [[NSBundle mainBundle] pathForResource:aktuellesBild ofType:@"jpg"]; 
    NSURL *url = [NSURL URLWithString:path]; 

    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; 
    [anleitungwebview loadRequest:request]; 

    NSLog(@"%@", aktuellesBild); 
} 

- (void)dealloc { 

    [anleitungwebview release]; 
    [laden release]; 
    [indicator release]; 
    [pdfpfad_anleitung release]; 
    [aktuellesBild release]; 
    [nummer release]; 
    [vor release]; 
    [super dealloc]; 
} 


@end 

誰ですか?

+0

あなたはゾンビを有効にしようとした文字列の長さをチェックしませんか? 「EXC_BAD_ACCESS」は、ほとんどの場合、解放されたオブジェクトにメッセージを送信するメモリの問題です。 –

+0

あなたのコードに2つのアクションが定義されていますが、どれが問題を引き起こしていますか?* zuruck *か* vor *? – lawicko

+0

その "vor"アクション、今度は "zombies"をDiagnosticsに有効にして、このメッセージを受け取ります: " - [CFString length]:メッセージが割り当て解除されたインスタンス0xa245670に送られました" –

答えて

0

あなたは

nummer = [aktuellesBild substringFromIndex:[aktuellesBild length]-3]; 
+0

"チェック"とはどういう意味ですか? NSLogまたは何ですか? –

+0

たとえば、[aktuellesBild length] = 2 – NeverBe

関連する問題