How to create view similar to AddressBook edit contact - iphone

Can anyone provide example of how to create contact view from address book.
Mostly I am interested in:
What UIKit class to use for Add Photo
What class to use for editing Name and Company
How to implement composite control where I am able to edit phone, ringtone
Thx

I'd recommend you check out the Address Book Programming guide for iPhone OS section at the iPhone Developer site.
The iPhone SDK comes with pre-built classes and views that can handle selecting, editing or adding of all the address book data. You simply create one of these pre-built controllers (e.g. ABPersonViewController) and fill in the ID of the person, and which details the user can select/change.

I've putted ImageView and a couple of TableViews with style set to Groped. I have one controller datasource for all my table views, that's why I set each table view tag property to unique int value to distinguish them in numberOfRowsInSection and cellForRowAtIndexPath.
Then everything is pretty standard, you are doing pushViewController and popViewControllerAnimated to show and hide details controller.
Works fine for me.

Apple's sample project QuickContacts covers this.

Related

Add event to calendar xcode?

I have a basic app with a list view with manualy added cells.
How would i make it so that when a cell is clicked , a specific date is added to the iphone calendar?
Info - using latest xcode with storyboards
You should have a delegate for you list view that response to the UITableViewDelegate protocol. By tableView:didSelectRowAtIndexPath: you can catch the click to your cell.
Then, use EKEventStore class to access your calendar. Your appointment is represented by an EKEvent.
EDIT
For more information you should consult the Introduction to Calendars and Reminders, Event Kit Framework Reference, and Table View Programming Guide.
This is the general approach, for a more detailed description you should tell, what your issues are and what did you try. Nobody at SO will write the program for you.

Return to mainview from webView deployed using storyboard

I created a new project "Single View Application" and designed the mainView with Storyboard. My main view contains a UIButton that opens the camera, the camera scans barcode and automatically goes to a website. Now I created a webView programmatically so that website can open and also created a UIButton inside the webView. Now I want that UIButton to act as home botton and return to mainview. I am unable to do that, please help.
ViewController.m code: http://cl.ly/FKj8
My storyboard looks like:
You really should look into the View Controller Programming Guide -- by switching around the contents of a single view controller, you're making a lot of extra work for yourself with little benefit. By using multiple view controllers when you want to have different "screens" in your app, you can take advantage of storyboarding for easier development, and you automatically get better memory management (read: less potential for crashes), too.
However, to more directly answer your question... if you're putting the WebView into the view hierarchy with [self.view addSubview:webView], you can remove it with [webView removeFromSuperview]. (This means you'll have to keep a reference to the WebView around so you can refer to it when you want to dismiss it.)
I also noticed in the code you posted to cl.ly an unrelated method -deviceModel which uses uname() to get device information. This is a bad idea, for two reasons:
uname() isn't guaranteed to do something useful on an iOS device (even if it currently does). Use the UIDevice class instead if you need this kind of info, or...
Generally, you don't want to test for the device name to enable functionality in your app; instead, you should test for the capabilities you need. (For example, if you look for a device name starting with "iPhone 4" to test for a Retina display, you'll miss the 4th-generation iPod touch, and the iPhone-5-or-whatever-they-call-what's-next. Instead, use the UIScreen class.)

How to get/set the rootViewController?

Now,I gonna Develop an App ,which wants to switch from many different Views irregularly,also the views need to load large resources,AKA,it's hard to manage memory.Are there any good solustion?
PS:I created a ViewController as RootViewController,and When a button was Touch,run the code as
"ViewController=newController"
.The problem came,The new View loaded wrong way,it rotate so that couldn't show in a correct way.
I google for the solution,some one said ,I should replace the rootViewController,just like that,
[UIApplication sharedApplication].delegate.window.rootViewController=newController;
But I can't get/set the rootViewController in other class though it's a singleton.
Why not having a class that handles all the view switches ?
This article describes an architecture that might be helpfull: http://www.mikeziray.com/2010/01/27/handling-your-initial-view-controllers-for-iphone/comment-page-1/#comment-607

How to implement admob on view controller?

In my app, I want to implement admob and now only I have started to learn about it. So any one please guide me and is there any nice tutorial or sample?
It's extremely simple. Follow the guide here: http://developer.admob.com/wiki/IPhone#AdMob_iPhone_SDK
Once you have the SDK up, you simply do:
AdMobView *ad = [AdMobView requestAdWithDelegate:<your delegate>]; // start a new ad request
ad.frame = CGRectMake(0, 432, 320, 48); // set the frame, in this case at the bottom of the screen
[self.window addSubview:ad]; // attach the ad to the view hierarchy; self.window is responsible for retaining the ad
Download the Admob SDK for iPhone and look at the example projects. It's very simple.
If you choose to use the Interface Builder approach and follow their steps
there is one step missing: Add an AdViewController object to your UIViewController.h/m file and use that as the referencing object in IB. Otherwise you'll get the error:
"Must implement required method
-currentViewControllerForAd:(AdMobView *)adView in your delegate"
I realize this is a basic assumption, but it caught me for a minute and i've implemented AdMob 3 times in the past (using different methods, mind you).
Add an ad to a view using Interface Builder
Add AdViewController.h and AdViewController.m to your project (located in the IBSupport subdirectory).
Open Interface Builder.
Place a 320x48 UIView where you want the ad to appear.
Add an Object, and change its type to AdViewController.
Set the view outlet of the AdViewController to your UIView.
Set the currentViewController outlet of the AdViewController
to the UIViewController owning the xib.
Edit AdViewController.m to make sure that your publisher ID and
other options are set correctly.
Good thing to know, Mike. They also left out one step in Interface Builder. You need to select File's Owner, and drag from Ad View Controller to the new Ad View Object. I simply cannot comprehend why Admob would leave out these details, especially when many new programmers join they're community all the time. They really need help in the documentation & tutorials department.

Where is the TableView loaded in the Navigational-based iPhone App

Using XCode's Navigational-based application project type, where is the code that loads the table view that is there by default?
There are a few delegate methods that compose your table view. Apple has a pretty good explanation with a sequence diagram that explains exactly how it is built and what each delegate method does: link text