2011-07-03 57 views
0

我试着去建立与查看swiching和UIWebView的 一个简单的应用程序,它的工作,直到我写了一个UIWebView线程1:程序接收到的信号:“SIGABRT”

-(IBAction)pushButton { 

    TermineViewController *screen = [[TermineViewController alloc] initWithNibName:nil bundle:nil]; 
    screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    [self presentModalViewController:screen animated:YES]; thread 1: program receved signal: "SIGaBRT" 
    [screen release]; 
} 

-(IBAction)pushButton2 { 

    SpeiseplanViewController *screen = [[SpeiseplanViewController alloc] initWithNibName:nil bundle:nil]; 
    screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    [self presentModalViewController:screen animated:YES]; 
    [screen release]; 




// 
// TermineViewController.m 
// LhAppv3 
// 
// Created by joan on 03.07.11. 
// Copyright 2011 __MyCompanyName__. All rights reserved. 
// 

#import "TermineViewController.h" 


@implementation TermineViewController 

-(IBAction)pushBack { 

    [self dismissModalViewControllerAnimated:YES]; 

} 

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

- (void)dealloc 
{ 
    [super dealloc]; 
} 

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

/* 
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
} 
*/ 

-(void)viewDidLoad { 

    [super viewDidLoad]; 
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.landheim-schondorf.de/news/"]]]; 
    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkLoad) userInfo:nil repeats:YES]; 
    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkNotLoad) userInfo:nil repeats:YES]; 

} 

-(void)checkLoad { 

    if(webView.loading) { 
     [active startAnimating]; 

    } 

} 

-(void)ckeckNotLoad { 

    if(!(webView.loading)) { 
     [active stopAnimating]; 

    } 

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

@end 


// 
// TermineViewController.h 
// LhAppv3 
// 
// Created by joan on 03.07.11. 
// Copyright 2011 __MyCompanyName__. All rights reserved. 
// 

#import <UIKit/UIKit.h> 


@interface TermineViewController : UIViewController { 

    IBOutlet UIWebView *webView; 
    IBOutlet UIActivityIndicatorView *active; 
} 

-(IBAction)pushBack; 

@end 
+0

请张贴崩溃的堆栈跟踪或_TermineViewController_的代码。这可能是导致错误的原因。 – Codo

+0

.h或.m的代码? – joan

+0

'.h或.m'的代码' - > – vikingosegundo

回答

1

您还没有创建视图。

-(void)viewDidLoad { 
    [super viewDidLoad]; 
    webView = [[UIWebView alloc] initWithFrame:aRect]; //<-------- 
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.landheim-schondorf.de/news/"]]]; 
    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkLoad) userInfo:nil repeats:YES]; 
    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkNotLoad) userInfo:nil repeats:YES]; 

} 

此外,您需要在dealloc中释放webView。而且你应该使用属性来舒适。

编辑
试图抓住错误僵尸的帮助:NSZombieEnabled

+0

好我现在写什么? – joan

+0

ich刚刚与这两个教程一起工作:http://www.youtube.com/watch?v=3P7sadlxBuQ http://www.youtube.com/watch?v=3P7sadlxBuQ – joan

+0

wirklich古特文档:http:// stackoverflow。 com/questions/5656626/learning-iphone-sdk-objective-c/5656783#5656783 Besonders Stanford mit Hagerty(但我们必须说英语:D) – vikingosegundo