- Registriert
- 08.12.08
- Beiträge
- 30
Ich habe mich mal zum Testen daran gemacht das Addressbook aus dem IPhone nachzubauen. Bekomm das eigentlich auch alles hin. Momentan habe ich allerdings ein Problem. Wenn ich mit ABNewPersonViewController einen neuen User anlege und Speicher wird die Tabelle nicht aktualiesiert. Ich habe es mit
probiert aber auch nichts. Erst nach einem Neustart der Application ist der / die neuen Kontakte sichtbar.
Im XIB hab ich tavleView, View, dataSource und Delegate mit dem FilesOwner verbunden. Da alles andere geht denke ich mal das haut hin. nur woran kann es liegen.
Hier mal ein bischen Code dazu (ein paar Sachen sind auskommentiert damit es nicht zu lang wird).
Edit: quote durch Code ersetzt
Code:
- (void)viewWillAppear:(BOOL)animated {
// Redisplay the data.
[[self tableView] reloadData];
}
Im XIB hab ich tavleView, View, dataSource und Delegate mit dem FilesOwner verbunden. Da alles andere geht denke ich mal das haut hin. nur woran kann es liegen.
Hier mal ein bischen Code dazu (ein paar Sachen sind auskommentiert damit es nicht zu lang wird).
Code:
.h
#import <UIKit/UIKit.h>
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
@class AddressBook;
@interface RootViewController : UITableViewController < UISearchBarDelegate, ABNewPersonViewControllerDelegate> {
AddressBook *dataController;
UIView *myView;
UITableView *tableView;
NSMutableArray *sectionArray;
int fullCount;
//for searchbar
UISearchBar *searchBar;
NSMutableArray *searchBarEntities;
}
@property (nonatomic, retain)AddressBook *dataController;
@property (nonatomic, retain)UIView *myView;
@property (nonatomic, retain)UITableView *tableView;
@property (nonatomic, retain)NSMutableArray *sectionArray;
-(void) addContact:(id) sender;
-(void) configureGroups:(id) sender;
@end
.m
-(void)loadView{
// create and configure the view
CGRect cgRct = CGRectMake(0, 40, 320, 380);
myView = [[UIView alloc] initWithFrame:cgRct];
myView.autoresizesSubviews = YES;
self.view = myView;
//create second View for searchbar
/*
*/
//Create tabelView
tableView = [[UITableView alloc] initWithFrame:cgRct style:UITableViewStylePlain];
tableView.editing = NO;
tableView.dataSource = self;
tableView.delegate = self;
self.title = @"B-AddressBook";
//addContact Button
UIButton* addContactViewButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
[addContactViewButton addTarget:self action:@selector(addContact:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *addContactButton = [[UIBarButtonItem alloc] initWithCustomView:addContactViewButton];
self.navigationItem.rightBarButtonItem = addContactButton;
[addContactViewButton release];
//add Group by Button
/*
*/
[self.view addSubview:tableView];
[myView release];
}
-(void) addContact:(id) sender {
ABNewPersonViewController *npvc = [[ABNewPersonViewController alloc] init];
npvc.title = @"Neuer Kontakt";
npvc.newPersonViewDelegate = self;
[[self navigationController] pushViewController:npvc animated:YES];
[npvc release];
}
- (void)newPersonViewController:(ABNewPersonViewController *)newPersonView didCompleteWithNewPerson:(ABRecordRef)person{
[[self navigationController] popViewControllerAnimated:YES];
}
Edit: quote durch Code ersetzt

Zuletzt bearbeitet: