Need some direction in building an iPhone app
I am building an iPhone app where I show the closest specialty restaurants to the user. I am using a navigation based application to do the development.
I want to let the user press a button on the first screen that allows him/her to go to screen 2.
From screen 2, here the user will see a table of all the restaurants close to the user.
Once the user selects开发者_JAVA技巧 a restaurant from this table, the user is taken to a third screen
Here, the user will see a map where the user will see where he/she is, and where the restaurant is located.
I will be using the CoreLocation framework to initially calculate the user's location, and then use this to search the database for locations close by. What I am confused about is, what method should I be doing this in the RootViewController? Would I place the button in the viewDidLoad() method, which would then trigger this method:
-(void)locationManager: (CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
Does this make sense?
There are a few different ways to do this.
Use a UITabBarController with three tabs, one for each of your views. When you want to auto-transition to the next screen, use
[myTabBarController setSelectedIndex:]
or[myTabBarController setSelectedViewController:]
.Pattern it after a flip-view "Utility Application." You can create a project using the Utility Application template for example code. The major difference is that instead of flipping from the backside to the front side, you're flipping to a third view controller.
Use a UINavigationController and
pushViewController:animated:
the second and third view controllers.
The actual CLLocationManagerDelegate stuff should probably live it the app delegate. Let the app delegate manage "global" data for the app.
I'd create a singleton class named for instance CurrentLocationProvider
with all the logic connected with updating location incapsulated inside it and call it's beginUpdateLocation
method in AppDelegate. It will be also great to provide user with a button that updates location explicitly when fired.
精彩评论