2012-02-23 4 views
0

"Touch Up Inside"로 UIButton을 터치 할 때마다 앱이 EXC_BAD_ACCESS로 두 번째로 충돌합니다. 나는 문제를 발견 할 수없고 모든 것이 좋다고 생각하지 않는다. 여기두 번째 터치 후 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

코드에서 * zuruck * 또는 * vor * 문제를 유발하는 두 가지 동작이 정의되어 있습니까? – lawicko

+0

"vor"조치 이제 진단을 통해 "좀비"를 활성화하고 다음 메시지를 얻습니다. "- [CFString 길이] : 해제 된 인스턴스 0xa245670에 메시지 전송" –

답변

0

당신은

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

"확인"무엇을 의미합니까? NSLog 또는 무엇? –

+0

예 : [aktuellesBild length] = 2 – NeverBe

관련 문제