-(void)... does not work/appeal (iOS)

Posted by user1012535 on Stack Overflow See other posts from Stack Overflow or by user1012535
Published on 2011-11-06T08:07:04Z Indexed on 2011/11/20 9:52 UTC
Read the original article Hit count: 272

Filed under:
|
|

Hi I've got a problem with my -(void) in my Xcode project for iOS. First of all here is the code

ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {
    IBOutlet UIWebView *webview;
    IBOutlet UIActivityIndicatorView *active;
    UIAlertView *alert_start;   
    UIAlertView *alert_error;   

}



-(IBAction)tele_button:(id)sender;
-(IBAction)mail_button:(id)sender;
-(IBAction)web_button:(id)sender;
-(IBAction)news_button:(id)sender;


@end

ViewController.m

#import "ViewController.h"

@implementation ViewController





- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];



    //Stop Bounce for WebView
    for (id subview in webview.subviews)
        if ([[subview class] isSubclassOfClass: [UIScrollView class]])
            ((UIScrollView *)subview).bounces = NO;



    //First Start Alert
    [alert_start show];
    NSLog(@"first alert"); 
    NSString *start_alert = [[NSUserDefaults standardUserDefaults] objectForKey:@"alert_start"];
    if(start_alert == nil)
    {
        [[NSUserDefaults standardUserDefaults] setValue:@"1" forKey:@"alert_start"];
        [[NSUserDefaults standardUserDefaults] synchronize];

        UIAlertView *alert_start = [[UIAlertView alloc] initWithTitle:@"iOptibelt" 
                                                              message:@"On some points this application need a internet connection." 
                                                             delegate:self 
                                                    cancelButtonTitle:@"OK"
                                                    otherButtonTitles:nil];

        [alert_start show];
        [alert_start release];

    }


// Do any additional setup after loading the view, typically from a nib.
    [webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"home-de" ofType:@"html"]isDirectory:NO]]];
     NSLog(@"webview fertig");
}

-(void)webViewDidStartLoad:(UIWebView *) webview {  
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    [active startAnimating];
    NSLog(@"lade"); 
}
-(void)webViewDidFinishLoad:(UIWebView *) webview { 
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    [active stopAnimating];
    NSLog(@"fertig"); 

}

-(void)webView: (UIWebView *) webview didFailLoadWithError:(NSError *)error{
     NSLog(@"lade error");     
    UIAlertView *alert_error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert_error show];
    [alert_error release];

};


- (IBAction)tele_button:(id)sender{
    NSLog(@"it's connected!");        
    //Local HTML Call Button
    NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"phone" ofType:@"html"]isDirectory:NO]];
    [webview loadRequest:theRequest]; 
}


- (IBAction)mail_button:(id)sender{
    NSLog(@"it's connected!");
    //Mail App Mail Button
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://[email protected]"]];
}
- (IBAction)web_button:(id)sender{
    NSLog(@"it's connected!");
    //Local HTML Button
    NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString: @"http://optibelt.com"]];
    [webview loadRequest:theRequest]; 
}

- (IBAction)news_button:(id)sender{
    NSLog(@"it's connected!");
    //local Home Button
    NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"home-de" ofType:@"html"]isDirectory:NO]];
    [webview loadRequest:theRequest]; 
}


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

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

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

@end

At last my 3. -(void) does not work and i ve no more idea what could be the problem....

-(void)webViewDidStartLoad:(UIWebView *) webview {  
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    [active startAnimating];
    NSLog(@"lade"); 
}
-(void)webViewDidFinishLoad:(UIWebView *) webview { 
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    [active stopAnimating];
    NSLog(@"fertig"); 

}

-(void)webView: (UIWebView *) webview didFailLoadWithError:(NSError *)error{
     NSLog(@"lade error");     
    UIAlertView *alert_error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert_error show];
    [alert_error release];

© Stack Overflow or respective owner

Related posts about ios

Related posts about xcode