-(void) problem :)

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • -(void) problem :)

    Hallo,

    ich hab ein kleines Problem mit meinen Voids, keines davon geht mehr.

    Weder die Notifikation noch der ActivityIndicator gehen,... jemand eine Idee?

    Bin leider als Anfänger mit meinem Latein am ende...



    ViewController.h

    Quellcode

    1. #import <UIKit/UIKit.h>
    2. @interface ViewController : UIViewController {
    3. IBOutlet UIWebView *webview;
    4. IBOutlet UIActivityIndicatorView *active;
    5. UIAlertView *alert_start;
    6. UIAlertView *alert_error;
    7. }
    8. -(IBAction)tele_button:(id)sender;
    9. -(IBAction)mail_button:(id)sender;
    10. -(IBAction)web_button:(id)sender;
    11. -(IBAction)news_button:(id)sender;
    12. @end
    Alles anzeigen



    ViewController.m



    Quellcode

    1. @implementation ViewController
    2. - (void)didReceiveMemoryWarning
    3. {
    4. [super didReceiveMemoryWarning];
    5. // Release any cached data, images, etc that aren't in use.
    6. }
    7. #pragma mark - View lifecycle
    8. - (void)viewDidLoad
    9. {
    10. [super viewDidLoad];
    11. //Stop Bounce for WebView
    12. for (id subview in webview.subviews)
    13. if ([[subview class] isSubclassOfClass: [UIScrollView class]])
    14. ((UIScrollView *)subview).bounces = NO;
    15. //First Start Alert
    16. [alert_start show];
    17. NSString *start_alert = [[NSUserDefaults standardUserDefaults] objectForKey:@"alert_start"];
    18. if(start_alert == nil)
    19. {
    20. [[NSUserDefaults standardUserDefaults] setValue:@"1" forKey:@"alert_start"];
    21. [[NSUserDefaults standardUserDefaults] synchronize];
    22. UIAlertView *alert_start = [[UIAlertView alloc] initWithTitle:@"LoreIpsum"
    23. message:@"LoreIpsum Lore Ipsum."
    24. delegate:self
    25. cancelButtonTitle:@"OK"
    26. otherButtonTitles:nil];
    27. [alert_start show];
    28. [alert_start release];
    29. }
    30. // Do any additional setup after loading the view, typically from a nib.
    31. [webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"home-de" ofType:@"html"]isDirectory:NO]]];
    32. NSLog(@"webview fertig");
    33. }
    34. -(void)webViewDidStartLoad:(UIWebView *) webview {
    35. [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    36. [active startAnimating];
    37. NSLog(@"lade");
    38. }
    39. -(void)webViewDidFinishLoad:(UIWebView *) webview {
    40. [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    41. [active stopAnimating];
    42. NSLog(@"fertig");
    43. }
    44. -(void)webView: (UIWebView *) webview didFailLoadWithError:(NSError *)error{
    45. NSLog(@"lade error");
    46. UIAlertView *alert_error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can't connect. Please check your internet connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    47. [alert_error show];
    48. [alert_error release];
    49. };
    50. //- (IBAction)tele_button:(id)sender;{
    51. // [[UIApplication sharedApplication] openU RL:[NSURL URLWithString:@"tel://00000000"]];
    52. - (IBAction)tele_button:(id)sender{
    53. NSLog(@"it's connected!");
    54. //Local HTML Call Button
    55. NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"phone" ofType:@"html"]isDirectory:NO]];
    56. [self->webview loadRequest:theRequest];
    57. }
    58. - (IBAction)mail_button:(id)sender{
    59. NSLog(@"it's connected!");
    60. //Mail App Mail Button
    61. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://info@loreipsum"]];
    62. }
    63. - (IBAction)web_button:(id)sender{
    64. NSLog(@"it's connected!");
    65. //Local HTML Button
    66. NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString: @"http://lore.com"]];
    67. [self->webview loadRequest:theRequest];
    68. }
    69. - (IBAction)news_button:(id)sender{
    70. NSLog(@"it's connected!");
    71. //local Home Button
    72. NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"home-de" ofType:@"html"]isDirectory:NO]];
    73. [self->webview loadRequest:theRequest];
    74. }
    Alles anzeigen







  • Quellcode

    1. [self->webview loadRequest:theRequest];


    Haha, da kann wohl jemand zu viel PHP, ne?!
    Probiert doch mal Objective-C, ich hab gehört, da kommt das iPhone ganz gut mit klar :D

    Quellcode

    1. [webview loadRequest:theRequest];
    (bzw. falls du noch Accessoren reinpackst

    Quellcode

    1. [self.webview loadRequest:theRequest];
    )

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von scriptedSheep ()

  • _smirk schrieb:




    ViewController.h

    Quellcode

    1. #import <UIKit/UIKit.h>
    2. @interface ViewController : UIViewController <UIWebViewDelegate>
    3. {
    4. IBOutlet UIWebView *webview;
    5. IBOutlet UIActivityIndicatorView *active;
    6. UIAlertView *alert_start;
    7. UIAlertView *alert_error;
    8. }
    9. -(IBAction)tele_button:(id)sender;
    10. -(IBAction)mail_button:(id)sender;
    11. -(IBAction)web_button:(id)sender;
    12. -(IBAction)news_button:(id)sender;
    13. @end
    Alles anzeigen


    [/color]


    Muss man nicht auch das "Delegate-Protokoll" im Interface angeben ??
  • Nein das muss man nicht. Das ist reine Formsache. Sprich wenn ich es angebe dann warnt mich der Compiler das ich eventuell was vergessen habe zu implementieren. Aber setzen tue ich es ja selber über xxx.delegate=self und damit werden dann die Delegate Methode bei mir angesprungen. Sind die allerdings dann nicht richtig implementiert kracht es natürlich

    Gruß

    Claus
    2 Stunden Try & Error erspart 10 Minuten Handbuchlesen.

    Pre-Kaffee-Posts sind mit Vorsicht zu geniessen :)
  • Wenn die Delegate-Referenz auf das Protokoll typisiert ist, muss es auch im Interface als Typ mit angegeben sein. Dann reicht die pure Implementierung nicht, die der Compiler ohnehin nicht an dieser Stelle überprüfen kann.
    Es hat noch nie etwas gefunzt. To tear down the Wall would be a Werror!
    25.06.2016: [Swift] gehört zu meinen *Favorite Tags* auf SO. In welcher Bedeutung von "favorite"?