Læser til Civilingeniør (Maskin), så kender lidt til programmering men ikke noget indenfor app programmering/objective C
Har fulgt en Turtorial på: https://developer.apple.com/library/ios ... Start.html
App'en består af
[Button]
First Name
Phone Number
Når man trykker på knappen/button går den ind i telefonbogen -> man vælger en kontakt -> den går tilbage og udfylder Navn og nummer.
Min app går desværre kun frem til telefonbogen, men hopper ikke tilbage og udfylder nummer og navn???
Har vedhæftet projektet.
Men her er også m.filen;
Hilsen
Niels
Kode: Vælg alt
//
// ViewController.m
// TukTuk
//
// Created by Niels kr on 07/05/15.
// Copyright (c) 2015 TukTuk. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)showPicker:(id)sender
{
ABPeoplePickerNavigationController *picker =
[[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentViewController:picker animated:YES completion:nil];
//[self presentModalViewController:picker animated:YES];
}
- (void)peoplePickerNavigationControllerDidCancel:
(ABPeoplePickerNavigationController *)peoplePicker
{
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
//[self dismissModalViewControllerAnimated:YES];
}
- (BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person {
[self displayPerson:person];
//[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
[self dismissModalViewControllerAnimated:YES];
return NO;
}
- (BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
return NO;
}
- (void)displayPerson:(ABRecordRef)person
{
NSString* name = (__bridge_transfer NSString*)ABRecordCopyValue(person,
kABPersonFirstNameProperty);
self.firstName.text = name;
NSString* phone = nil;
ABMultiValueRef phoneNumbers = ABRecordCopyValue(person,
kABPersonPhoneProperty);
if (ABMultiValueGetCount(phoneNumbers) > 0) {
phone = (__bridge_transfer NSString*)
ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
} else {
phone = @"[None]";
}
self.phoneNumber.text = phone;
CFRelease(phoneNumbers);
}
@end