I have a query regarding AddressBookUI
ABPersonViewController *personController=[[ABPersonViewController alloc] init];
ABAddressBookRef addressBook=ABAddressBookCreate();
//ABRecordRef aRecord=ABAddressBookGetPersonWithRecordID(addressBook, 25);
personController.displayedPerson=ABAddressBookGetPersonWithRecordID(addressBook, uniqueID);
personController.addressBook=addressBook;
personController.personViewDelegate=self;
personController.allowsEditing=YES;
[[self navigationController] pushViewController:personController animated:YES];
[personController release];
to show cotacts corresponding to a uniqueID
but when the view appears and I press the edit button
add fields option Appear, I want to hide this option.
Can this be done?????
If yes kindly suggest me some work around.
Thnx in advance.
That is how the standard Edit Contact view works.
You could write your own view&controller that reads the contacts values, puts them in input fields, and after the user has edited them, saves the contact. But that is quite a lot of work, and I would recomment that you use the standard View anyway.
In my opinion, it is better to use standard GUI elements as much as possible.
Related
Let me explain what i want to do first. In native Iphone in the Recents tab if you click on a contact not found in any addressbook you have an option to "Add to Existing Contact"
After clicking on "Add to Existing Contact", a picker shows up and you make a selection. Afterwards it brings you to a ABPersonViewController automatically and allows you to edit or save the new contact:
I am trying to recreate this but having some issues. In my version, After I create the UnknownPersonViewController and the end user presses "Add to Existing Contact" a picker shows up and allows for selecting from the addressbook similar to native Iphone. But after making a selection the name gets automatically added to the addressbook and no personViewController appears to give the user a choice to add the contact or not. Even if i could just get it to not auto write to the addressbook after making a selection i could just have it show a personviewcontroller in edit mode right away.
So my issue is why is it automatically updating the addressbook after making a selection?
Im pushing the ABUnknownpersonviewcontroller onto a UITableviewController navigationcontroller. and im testing on a physical device with iOS 6.01
Here is some code:
ABRecordRef person = ABPersonCreate ();
ABMutableMultiValueRef multiValue = ABMultiValueCreateMutable(kABStringPropertyType);
ABMultiValueAddValueAndLabel(multiValue, call.number, kABPersonPhoneMainLabel,
NULL);
ABRecordSetValue(person, kABPersonPhoneProperty, multiValue, error);
if(multiValue) CFRelease(multiValue);
ABUnknownPersonViewController *unknownCtrl = [[ABUnknownPersonViewController alloc] init];
unknownCtrl.displayedPerson = person; //this has a phone number with "main" label
unknownCtrl.allowsActions = YES;
unknownCtrl.allowsAddingToAddressBook = YES;
unknownCtrl.editing=NO;
unknownCtrl.unknownPersonViewDelegate = self;
// unknownCtrl.addressBook=ABAddressBookCreate(); // I tried setting addressbook to nil and object
unknownCtrl.addressBook=nil;
[self setTitle:call.type forUIViewController:unknownCtrl];
[self.navigationController pushViewController:unknownCtrl animated:YES];
note: i have a similar problem to this post : http://forums.macrumors.com/archive/index.php/t-1023140.html
and perhaps https://discussions.apple.com/thread/1682620?start=0&tstart=0
UPDATE: it seems if i put the kABPersonPhoneMainLabel from the person, then it does not write the phone number to the contact. Aftewards what i did was in didResolveToPerson delegate i call the personviewcontroller in edit mode. This simulates the native behavior. This may answer my own question, thanks everyone.
ABUnknownPersonViewController doesn't expose many customization options, you need to implement your own version. It's not too hard though - the "Create New Contact" button just launches an ABNewPersonViewController, and the "Add to Existing Contact" launches an ABPeoplePickerNavigationController. Your ViewController should act as the delegates for those objects and controls what happens when they are completed.
my original title was How to customize TTMessageController for SMS transmission?. I changed this now because I look for any possible solution and not only those with TTMessageController.
Well, I am working on an simple application in xcode4. The user should be able to send SMS from different SMS gateways.
The background logic is quite simple because everything is managed by executing some http requests on an rest api.
The hard thing for me now is to setup the UI and that is where I need help because I am new to iOS development. This is how I want it to be:
http://img222.imageshack.us/img222/3159/bhrfe.png
There should be a recipient picker to either do autosearch on contacts or to directly pick a contact from the contact list. Beside I want only one recipient. And there should be a text area.
I also want to have a label somewhere at the bottom to show the current char number.
Since I did not find those UI elements in xcode4 library I searched for something similar and I found the TTMessageController which gives me the view you see in the picture.
However plus button does not work and I am not sure how to extend all this to do what I want.
I appreciate any idea on this.
For the + Button you can use the address book UI:
// This Code is taken from Apple's sample code QuickContacts
#import <AddressBookUI/AddressBookUI.h>
-(void)showPeoplePickerController {
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
// Display only a person's phone, email, and birthdate
NSArray *displayedItems = [NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]];
picker.displayedProperties = displayedItems;
// Show the picker
[self presentModalViewController:picker animated:YES];
[picker release];
}
The <ABPeoplePickerNavigationControllerDelegate> delegate include this methods:
– peoplePickerNavigationController:shouldContinueAfterSelectingPerson:
– peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:
– peoplePickerNavigationControllerDidCancel:
After selecting a person you can save his/her number in an array and in the text field (e.g. comma separated)
.
For the question if it will be approved here is the guideline:
https://developer.apple.com/appstore/resources/approval/guidelines.html
22.6 Apps that enable anonymous or prank phone calls or SMS/MMS messaging will be rejected
You can't use TTMessageController to send sms. The only possible way to send sms is to use MFMessageComposeViewController. Here's a tutorial on how to use it: http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/
I have implemented a basic add contact feature to an iOS 4 application. Following the documentation from Apple, I have created a navigation controller, and set its root view to the ABNewPersonViewController. I have implemented the delegate as well. The basic mechanics all work.
The problem I am having is when you add a photo to the new person that is very large (taking a photo or picking one from the library), the ABNewPersonViewController form returns empty when the camera controls are dismissed. No photo is in the add photo box either. If I pick a small image (say a screenshot from the iPhone), everything works. I can see from the debug output: Received memory warning. Level=1
Has anyone else run into this? Is there a way to set the photo quality to a lower setting for the ABNewPersonViewController? Any help appreciated.
ABNewPersonViewController *abNewPersonView = [[ABNewPersonViewController alloc] init];
abNewPersonView.newPersonViewDelegate = self;
UINavigationController *newNavigationController = [UINavigationController alloc];
[newNavigationController initWithRootViewController:abNewPersonView];
[self presentModalViewController:newNavigationController animated:YES];
[abNewPersonView release];
[newNavigationController release];
If ABNewPersonViewController does not handle memory warnings correctly, file a bug with apple.
I'm playing around with this application I got on last months Web Designer that's a very basic RSS reader. I would like to add a refresh button to the top navigation bar that refreshes all the content in the table but can't seem to work out how to do it. I've worked out it must somehow use the [tablename Reload] function, but have got no idea how to implement it.
I'm new to all this so simple instructions are good instructions :) I know how to add the button, its linking it to and defining the actions when the user clicks it that I'm struggling with.
You can grab the code here http://www.webdesignermag.co.uk/tutorial-files/issue-162-tutorial-files/ under iPhone Apps (it's the only one).
This is what you need to do in the RootViewController.m:
In the viewDidLoad function, add a button of type UIBarButtonSystemItemRefresh, associate to it an Action and a Target, (infact, as Alan told you, you need to learn about Outlets and Actions)
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:#selector(refreshTable)];
self.navigationItem.rightBarButtonItem = refreshButton;
Implement refreshTable function (if not declared in .h, have to put it above viewDidLoad())
- (void)refreshTable{
[rssParser release];
rssParser = [[RSSXMLParser alloc] init];
[rssParser parseRSSFeed];
[self.tableView reloadData];
NSLog(#"table is refreshing ....");
}
Hi Graeme and velcome to SO.
For the iphone UI, you have to define outlets and actions, and use Interface Builder to link them together.
This page has some information that should hopefully get you started.
Understanding Outlets and Actions
This is probably an easy thing to do, but I just can't figure it out - how do I end editing athe textview? how can I get the keyboard to disappear? or do I have to click outside it to make it go away?
First, a (to be honest) fairly simple question like this makes me wonder if you've tried reading the documentation, or searching on the internet.
Searching for "Apple documentation UITextView" gives you this link to the class documentation. Similarly, here is the documentation for the UITextViewDelegate.
Searching for "UITextView simple example" gives you this useful example.
Searching for "UITextView dismiss keyboard", the first hit seems to answer your question exactly. (Although he dismisses the keyboard on a return key, which may not be what you want.) (Edit - it seems from your second comment it's exactly what you want.)
P.S. The people above are correct, if a little terse (understandably). You need to implement a UITextViewDelegate. In that delegate, if you want to hide the keyboard on a return key, implement shouldChangeTextInRange, look for a #"\n" and resign first responder if you get it. Alternatively, add a "Done editing" button to your UI, and resign first responder if the user presses it.
Very Easy:
[myTextField resignFirstResponder];
will do the trick.
One way to end editing, tapping outside the textView, is not entirely trivial. Selecting other text views or text fields or activating a navigation control will trigger...
- (void)textViewDidEndEditing:(UITextView *)textView
...on whatever object you've designated as the textView's delegate. You can trigger this yourself by calling...
- (BOOL)endEditing:(BOOL)force
...on the view that contains your text field.
Suppose I have a UITextView inside a UITableViewCell (inside a UITable). I want to enable editing to end by tapping the table. I could do this:
- (void)viewDidLoad
{
[super viewDidLoad];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(didTapTable)];
[[self tableView] addGestureRecognizer:tapRecognizer];
[tapRecognizer release];
}
- (void)didTapTable
{
[[self tableView] endEditing:YES];
}
Now whenever I tap my table, I end editing. And, as others have said, in textViewDidEndEditing I should be sure to call [textView resignFirstResponder];
[yourTextField resignFirstResponder];
will make the keyboard disappear and editing end.