• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Was gibt es Schöneres als den Mai draußen in der Natur mit allen Sinnen zu genießen? Lasst uns teilhaben an Euren Erlebnissen und macht mit beim Thema des Monats Da blüht uns was! ---> Klick

Einige kleine Fragen zu meiner App

Thaddäus

Golden Noble
Registriert
27.03.08
Beiträge
18.399
Hi Leute...

Bin gerade mal wieder an meiner App am brüten und komm grad nicht weiter. Ich möchte in den Einstellungen oben rechts einen Creditsbutton haben. Ich habe mir dazu folgenden Code in die SettingsViewController.m geschrieben:

Code:
//
//  SettingsViewController.m
//  RSSReader
//
//  Created by Stephan König on 25/06/10.
//  Copyright 2010 Stephan König. All rights reserved.
//

#import "SettingsViewController.h"


@implementation SettingsViewController

/*
- (id)initWithStyle:(UITableViewStyle)style {
    // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
    if (self = [super initWithStyle:style]) {
    }
    return self;
}
*/


- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"Einstellungen";
}


/*
- (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];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
[COLOR=Blue]*/

- (IBAction)about:(id)sender {
    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"Credits" 
                          message:@"Name der App \n \n\nIdee: Stephan König \n\nProgrammierung: Stephan König \n\nSplashcreen: \n\nStephan König 2010 Alle Rechte vorbehalten"
                          delegate:self
                          cancelButtonTitle:@"OK"
                          otherButtonTitles:@"Kontakt"
                          ,nil];
    [alert show];
    [alert release];
}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 1)
    {
        NSArray *recipients = [[NSArray alloc] initWithObjects:@"meine Email-Adresse", nil];
        MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
        controller.mailComposeDelegate = self;
        [controller setToRecipients:recipients];
        [recipients release];
        [self presentModalViewController:controller animated:YES];
        [controller release];
    }
}[/COLOR]

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}

#pragma mark Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }
    
    // Set up the cell...

    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.
    // AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
    // [self.navigationController pushViewController:anotherViewController];
    // [anotherViewController release];
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/


/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/


/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/


/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

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

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


@end
Das Problem ist aber, dass mir da kein Button angezeigt wird. Ausserdem wirft mir das ganze einen Fehler aus. Dazu habe ich den Screenshot angehängt.

Die zweite Frage bezieht sich auf die Einbindung von eigenen RSS-Feeds: Kennt da jemand ein gutes Tutorial, wie man das am einfachsten und saubersten realisieren kann?
 

Anhänge

  • Bildschirmfoto 2010-06-27 um 22.12.45.jpg
    Bildschirmfoto 2010-06-27 um 22.12.45.jpg
    46,8 KB · Aufrufe: 173
  • Bildschirmfoto 2010-06-27 um 22.35.56.jpg
    Bildschirmfoto 2010-06-27 um 22.35.56.jpg
    23,9 KB · Aufrufe: 136
Zuletzt bearbeitet:

sheep

Fießers Erstling
Registriert
09.11.07
Beiträge
126
Hast du das MessageUI framework eingebunden?

Beim zweiten Fehler fehlt die geschweifte Klammer (viewDidAppear).
 

Thaddäus

Golden Noble
Registriert
27.03.08
Beiträge
18.399
Ja, das MessageUI Framework ist drin, der Fehler kommt aber nach wie vor... :( Ich hab das einfach aus dem Finder in den Ordner Frameworks reingezogen...

Das zweite habe ich beheben könne, habe ich glatt übersehen...

EDIT: Das sind übrigens die zwei Fehler die noch kommen:

error: 'MFMailComposeViewController' undeclared (first use in this function)

error: 'controller' undeclared (first use in this function)
 
Zuletzt bearbeitet:

Poljpocket

Salvatico di Campascio
Registriert
07.01.07
Beiträge
432
Dann weisst du ja, nach was du suchen musst.

Erstens ist die Klasse "MFMailComposeViewController" nicht bekannt (in diesem scope), also hast du wahrscheinlich einen Header nicht importiert (oder es gibt diese Klasse gar nicht).

Zweitens ist controller in diesem scope anscheinend nicht deklariert.

Gruss ppocket

PS: Gerade ist mir aufgefallen:

Ja, das MessageUI Framework ist drin, der Fehler kommt aber nach wie vor... :( Ich hab das einfach aus dem Finder in den Ordner Frameworks reingezogen...

Du musst die Header aus dem Framework jetzt noch in deinen Code importieren! So, à la

Code:
#import <MessageUI/MessageUI.h>
 

Poljpocket

Salvatico di Campascio
Registriert
07.01.07
Beiträge
432
... siehe nächsten Beitrag. Sorry für den Fehler, aber mein Browser hat das selber durchgezogen! :p
 

Poljpocket

Salvatico di Campascio
Registriert
07.01.07
Beiträge
432
Es gibt drei scopes, dabei geht es um Gültigkeitsbereiche von Variablen/Objekten innerhalb des Codes:

1 - file scope:

Code:
const char meinName[] = "Jonas";

int main(void) {
   [...]
};

int funktion(void) {
   [...]
};

[...]

diese Variable ist im gesamten file verfügbar, da sie nicht innerhalb einer Funktion deklariert wurde. Wenn du nicht noch 'static' davorsetzt, ist diese Variable auch in allen anderen Dateien, welche diese impotieren verfügbar.

2 - function scope

Code:
const char meinName[] = "Jonas";

int main(void) {
   int meineNummer = 3;
   [...]
};

int funktion(int n, [...]) {
   [...]
};

[...]

Variablen, welche innerhalb eines Funktionsblockes deklariert wurden, befinden sich im function-scope, dh: Sie sind nur innerhalb der Funktion verfügbar. Gleiches gilt übrigens für alle Argumente, welche der Funktion übergeben werden.

3 - block scope
Code:
const char meinName[] = "Jonas";

int main(void) {
   int meineNummer = 3;
   {
      int machWas = 0;
      [...]
   };
   [...]
};

int funktion(int n, [...]) {
   [...]
};

[...]

die main-Funktion enthält jetzt so einen Block. Variablen, welche innerhalb dieses Blocks definiert wurden, sind ausserhalb nicht verfügbar.


Es ist noch anzumerken, dass Variablen aus scope 1 und 2 in 3 auch verfügbar sind und dasselbe gilt für Variablen aus scope 1 in scope 2.

Gruss ppocket

PS: Alle if-Verzweigungen, while-, do-while- und for-Schleifen, usw... gehören zu den Blöcken, also scope 3. Dies ist zum Beispiel der Grund, warum du im C99-Standard immer wieder

Code:
for(int i = 0, [...]) {

};

schreiben darfst, ohne, dass der compiler meckert, i sei längst definiert worden.
 
  • Like
Reaktionen: Thaddäus

Poljpocket

Salvatico di Campascio
Registriert
07.01.07
Beiträge
432
Den ersten Fehler bringst du also tatsächlich mit meinem Code raus (also der Framework-Header-Import). Was mit dem controller ist, musst du selber rausfinden, der steht dort irgendwie im Schilf - total! :) So genau hab ich das nicht angeschaut, aber könnte es sein, dass anstatt 'controller' dort 'self' stehen müsste??

Gruss ppocket

PS: Das MailComposeDelegate-Protokoll musst du im Klassenheader noch einfügen und die benötigten Methoden in der Implementation behandeln.