ABPeoplePickerNavigationController with editable ABPersonViewController - iphone

I am using an ABPeoplePickerNavigationController to display contacts. When a user selects a contact that contact's info is displayed in what I'm assuming is a ABPersonViewController - this is the behavior that I want. At this point, I would like to be able to edit the contact data by providing an edit button in the righthand side of the ABPeoplePickerNavigationController's navigation bar. Can this be done?
I've tried several things including pushing my own ABPersonViewController onto the navigation controller but even with the 'allowsEditing' flag set and the navigation controller's 'rightBarButtonItem' set to an UIBarButtonSystemItemEdit it wouldn't show the edit button?

just set ABPersonViewController's property allowsEditing and editing YES. Then you can control the saving action.

Related

Making a UITabView show the second level of a navigation controller by default

(Apologies for not being able to embed my images yet).
Using iOS storyboards, I have a UITabBarController with a UINavigation Controller/UITableView(1) embedded in it. This UITableView(1) then calls another UITableView(2):
What I'm trying to do is to make UITableView(2) appear when the Tab Bar is changed to that tab, and then have the UINavigationBar left arrow button exist to get back to UITableView(1).
The existing functionality I can think of which does this is the iPhone Mail app, where when you launch it you see your Inbox, and you can hit the left-arrow Mailboxes button to get back to your mail box list.
I've tried attaching the tab bar directly to UITableView(2) but it doesn't work as expected, there's no left arrow back button to get back to the previous view when the app is run.
I've also tried adding a navigation controller to that UITableView(2) and the Navigation controller correctly appears, but still without any back button:
Any suggestions as to what I'm doing wrong would be greatly appreciated, I'm fairly new with storyboards and it's difficult to find what to search to get this working.
If it's not possible with just storyboards themselves, is there some kind of automatic (non-visible) push to the 2nd UITableView I could do?
Thanks!
Nick.
This tutorial will definitely help you : http://maybelost.com/2011/10/tutorial-storyboard-in-xcode-4-2-with-navigation-controller-and-tabbar-controller-part1/
I ended up implementing it the following way, as I wanted to perform the majority of the work within storyboards.
I set up the storyboard with the tab bar embedding the UINavigationController, which contained UITableView(1) which then contained a custom segue to UITableView(2):
Then within the class associated with UITableView(1) I added this single line:
- (void)viewDidLoad {
[self performSegueWithIdentifier:#"campaigns" sender:self];
...
}
On load of the tab, the viewDidLoad of UITableView(1) instantly calls UITableView(2) without any kind of animation, showing the back button to UITableView(1), which is exactly what I wanted.
Thanks to those who responded!
You can implement the delegate method as below.
(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
In this method you can check for the tabBarController.selectedIndex or viewController object. This ensures the selection of correct tab , then push the controller having table 1, then push the controller having table 2.

How to disable backBarButtonItem displayed in current view?

After a view has been pushed onto the UINavigationController stack and is displayed I need to disable the Back button under certain circumstances, e.g., when data is being edited on that screen.
The following hides the Back button
self.navigationItem.hidesBackButton=YES;
but I need to disable it.
There are several other answers about how to hide it or suggest not displaying it in the first place, but these are not what I need to implement.
You could implement one of the delegate methods for your navigationController's navigation bar delegate. Take a look at the [UINavigationBarDelegate navigationBar:shouldPopItem:] method.
Returning YES or NO from this method will enable or disable the back button.
You could implement one leftBarButtonItem (invisible and without effect)
add it into your current view (self.navigationItem.leftBarButtonItem)
and remove it to access your backButton.
If you're fine that the whole navigation bar is disabled, an easy solution is
self.navigationController.navigationBar.userInteractionEnabled = NO;
Of course this doesn't work if you have other bar buttons that you want to keep enabled.

In which method should I set my UIToolBar hidden

I have been coding in iphone platform for about a few months. One thing I am still to understand is in which method exactly should I set the navigation bar/toolbar/barButtonItem hidden.
In my project sometimes I set in - (void)viewDidLoad, sometimes I set in - (void)viewWillAppear:(BOOL)animated. Sometimes I set it from where I push the navigation controller.
I think I am not understanding the basics correctly. If one way is not working, I try the other way and somehow it works.
If I am to hide the toolbar or barbuttonitem in navigation controller, where exactly should I set that.
Edit:
If I am pushing a new navigation controller, in which I want my toolbar hidden, where should I set it hidden. Similarly, when I pop it, I want the the toolbar to be shown, where should I set the toolbarHidden property to 'NO'.
Similarly, I have a navigation controller, sometimes it needs to show the toolbar and sometimes it needn't, where should I check the condition for this case.?
You should set this property before the pushing the view Controller and don't need to set No at pop. E.g see the following link:
hiding tabbar on table view cell click

how to get done in button like in favorites tab of iphone phone app

how can i get done button like in favorites tab of native phone app which appears after we click edit button in favorites tab .
i though they were two barbutton items , hiding according to need ,but when i tried to place new barbutton item on my old one , old one replacing and new one only existing :S
thanks in advance
regards
If you have a UITableViewController UIViewController subclass, this is provided for you as the editButtonItem property. You can set either bar button item of your navigation bar to that and you will get the behavior out of the box.
[self.navigationItem setRightBarButtonItem:self.editButtonItem];
You may need to provide a setEditing:animated: implementation to transition your views to and from the editing state if you're not using a UITableViewController.

How to remove searchResultsTableView?

I have a UISearchDisplayController that displays some cells after a user has searched. After the user clicks on the cell, I am pushing a new view to my nav stack. How can I remove searchResultsTableView from the view so that when the user goes back, he doesn't see the searchResultsTableView?
See the documentation of UISearchDisplayController it sais:
setActive:animated:
Displays or hides the search interface, optionally with animation.
- (void)setActive:(BOOL)visible animated:(BOOL)animated
Parameters
visible
YES to display the search interface if it is not already displayed; NO to hide the search interface if it is currently displayed.
animated;
YES to use animation for a change in visible state, otherwise NO.
Discussion
When the user focus in the search field of a managed search bar, the search display controller automatically displays the search interface. You can use this method to force the search interface to appear.
Availability
Available in iPhone OS 3.0 and later.
Declared In
UISearchDisplayController.h