如何在iPhone应用程序中打开编辑联系人窗口?

发布于 2024-12-22 03:06:59 字数 1707 浏览 2 评论 0原文

我正在通过单击“添加联系人”从我的 iPhone 应用程序添加联系信息。我只想在同一“添加联系人”单击上打开编辑联系人窗口,以便用户可以编辑或删除刚刚添加的联系人。我已经做了如下的事情..

- (IBAction)AddContact
 {   
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef Showroom = ABPersonCreate();

//adding contact name as showroom name

ABRecordSetValue(Showroom, kABPersonFirstNameProperty, ShowroomName.text , nil);
   ABAddressBookAddRecord(addressBook, Showroom, nil);
ABAddressBookSave(addressBook, nil);
// Fetch the address book 
//ABAddressBookRef addressBook = ABAddressBookCreate();
// Search for the person named "Appleseed" in the address book

    //ABRecordRef Showroom = (ABRecordRef)[Showroom objectAtIndex:0];
    ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease];
    picker.personViewDelegate = self;
    picker.displayedPerson = Showroom;
    // Allow users to edit the person’s information
    picker.allowsEditing = YES;
[self.navigationController pushViewController:picker animated:YES];
}

这是我的地图应用程序。启动后,我得到了与那里的联系人的陈列室结果。我可以通过打开编辑联系人窗口将其添加到 iPhone 联系人中。但是当我打开其他控制器将用户选择的字符串地址传递到地图控制器以搜索陈列室位置时。上面的代码不起作用。我的意思是它只添加联系人,但我没有得到编辑联系人窗口。

编辑: 可能这个问题与导航控制器栏有关,所以还要检查下面的代码

- (void)viewWillAppear:(BOOL)animated 
   {
  [self.navigationController setNavigationBarHidden:YES animated:animated]; 
   } 
   - (void)viewDidLoad {

[self.navigationController setNavigationBarHidden:NO ];
self.navigationController.navigationBar.tintColor = [UIColor  colorWithRed:25.0/255.0f green:25.0/255.0f blue:25.0/255.0f alpha:1.0f];
   }
- (void)viewWillDisappear:(BOOL)animated
{ 
[self.navigationController setNavigationBarHidden:NO animated:animated];
 }

I am adding contact info from my iPhone application on Addcontact click. I just want to open edit contact window on same Addcontact click so user can edit or delete the contact which just now have added. I have done smthing like below..

- (IBAction)AddContact
 {   
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef Showroom = ABPersonCreate();

//adding contact name as showroom name

ABRecordSetValue(Showroom, kABPersonFirstNameProperty, ShowroomName.text , nil);
   ABAddressBookAddRecord(addressBook, Showroom, nil);
ABAddressBookSave(addressBook, nil);
// Fetch the address book 
//ABAddressBookRef addressBook = ABAddressBookCreate();
// Search for the person named "Appleseed" in the address book

    //ABRecordRef Showroom = (ABRecordRef)[Showroom objectAtIndex:0];
    ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease];
    picker.personViewDelegate = self;
    picker.displayedPerson = Showroom;
    // Allow users to edit the person’s information
    picker.allowsEditing = YES;
[self.navigationController pushViewController:picker animated:YES];
}

this is my Map application. On launching I get showroom results with there contacts. This I can add in to the iPHone contact with edit contact window opening. But when I open other controller to pass user selected string address in to Map controller to search showroom location. The same above code is not working. I mean it only add the contacts but I didnt get the edit contact window.

Edit:
May be this problem is regarding navigation controller bar so check the below code also

- (void)viewWillAppear:(BOOL)animated 
   {
  [self.navigationController setNavigationBarHidden:YES animated:animated]; 
   } 
   - (void)viewDidLoad {

[self.navigationController setNavigationBarHidden:NO ];
self.navigationController.navigationBar.tintColor = [UIColor  colorWithRed:25.0/255.0f green:25.0/255.0f blue:25.0/255.0f alpha:1.0f];
   }
- (void)viewWillDisappear:(BOOL)animated
{ 
[self.navigationController setNavigationBarHidden:NO animated:animated];
 }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九公里浅绿 2024-12-29 03:06:59

我希望这段代码对你有用,我实现了该代码,并且在我的应用程序中工作得很好,谢谢

contecviewcontroller.h
@interface DetailsViewController : UIViewController
DocumentNavController *coffeeObj;
editViewController *evController;
int currentindex;
}

@property (nonatomic, retain) DocumentNavController *coffeeObj;
@property (readwrite, assign) int currentindex;    
@end

contecviewcontroller.m

- (void)viewDidLoad {
  [super viewDidLoad];
//self.navigationController.toolbar.tintColor = [UIColor darkGrayColor];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
                                           initWithBarButtonSystemItem:UIBarButtonSystemItemEdit 
                                           target:self action:@selector(goToEdit)]autorelease];
}


-(void)goToEdit{

if(evController == nil)
    evController = [[editViewController alloc]initWithNibName:@"editViewController" bundle:nil];
evernoteAppDelegate *appdelegete = (evernoteAppDelegate *)[[UIApplication sharedApplication]delegate];
coffeeObj = [appdelegete.noteArray objectAtIndex:currentindex];

evController.Editcurrentindex = currentindex;
evController.docedObj = coffeeObj;
[self.navigationController pushViewController:evController animated:YES];
}

I hope this code is works for you i implements that code and in my application works fine thank you

contecviewcontroller.h
@interface DetailsViewController : UIViewController
DocumentNavController *coffeeObj;
editViewController *evController;
int currentindex;
}

@property (nonatomic, retain) DocumentNavController *coffeeObj;
@property (readwrite, assign) int currentindex;    
@end

contecviewcontroller.m

- (void)viewDidLoad {
  [super viewDidLoad];
//self.navigationController.toolbar.tintColor = [UIColor darkGrayColor];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
                                           initWithBarButtonSystemItem:UIBarButtonSystemItemEdit 
                                           target:self action:@selector(goToEdit)]autorelease];
}


-(void)goToEdit{

if(evController == nil)
    evController = [[editViewController alloc]initWithNibName:@"editViewController" bundle:nil];
evernoteAppDelegate *appdelegete = (evernoteAppDelegate *)[[UIApplication sharedApplication]delegate];
coffeeObj = [appdelegete.noteArray objectAtIndex:currentindex];

evController.Editcurrentindex = currentindex;
evController.docedObj = coffeeObj;
[self.navigationController pushViewController:evController animated:YES];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文