iphone and gis development notes

By Rupert

Follow me on TwitterRSS Feeds

  • Home
  • About

iPhone Note #17: Displaying a custom view controller from a UITextField

Nov 2nd

Posted by rupert in iphone

No comments

Problem: I want my textFieldSearchAddress to display a seperate viewcontroller.

textfield.png

Short Answer: Hide the keyboard by using

[textField resignFirstResponder]

then show the view controller.

1. Implement a UITextFieldDelegate.

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
	[textField resignFirstResponder];
	[self show];
	return NO;
}

Be careful with the BOOL return of textFieldShouldBeginEditing. From the docs: “YES if an editing session should be initiated; otherwise, NO to disallow editing.”

2. Show the view controller.

- (IBAction)show{
	NSLog(@"show");
 
	AddressViewController *addressViewController = [[AddressViewController alloc] initWithNibName:@"AddressViewController" bundle:nil];
	UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:addressViewController];
	[self presentModalViewController:nav animated:YES];
 
	[addressViewController release];
	[nav release];
 
}

Download SimpleIB-textfield_custom_view_controller.zip

iphone

Subversion

Nov 1st

Posted by rupert in subversion

No comments

This post will contain a summary of information regarding subversion scattered from old posts.

Installation on Debian

1. Packages

#apt-get install subversion
#apt-get install libapache2-svn

2. Login as root then create the repository.

#cd /data
#svnadmin create /repos --fs-type fsfs

3. Set the permissions

#groupadd subversion
#addgroup rupert subversion
#addgroup www-data subversion
 
#chown -Rf www-data:subversion /data/repos
#chmod -Rf 770 repos

It’s better to set the necessary users and groups that would use subversion now. Later on, if we need to checkout using svn+ssh and setup a passwordless svn, then we won’t get permission issues.

4. In /etc/apache2/sites-available/2rmobile, add this to the configuration.

        <Location /repos>
        DAV svn
        SVNPath /data/repos
        SVNAutoversioning on
        AuthType Basic
        AuthName "SVN - Your Project"
        AuthUserFile /data/svn-auth-file
        Require valid-user
        </Location>

5. Enable the webdav module then restart apache.

#a2enmod dav
#a2enmod dav_svn
#/etc/init.d/apache2 restart

Passwordless SVN

On your local macbook pro (mbp), we need to generate the ssh keys from the local machine, upload it to the remote machine and append it in the authorized_keys.

On the local machine:

#ssh-keygen -t rsa
...
#cd /Users/rupert/.ssh
#scp -r id_rsa.pub rupert@2rmobile.com:/home/rupert/.ssh/id_rsa_mbp.pub

On the remote machine:

#cd ~/.ssh
#touch authorized_keys
#cat id_rsa_mbp.pub >> authorized_keys

Test on the local machine by doing

ssh rupert@2rmobile.com

. In my mbp, a dialog box from keychain is asking for the password. To circumvent this, we can add the passphrase to our identities.

#ssh-add -K
... enter the passphrase twice...
#ssh-add -k (adds it to the identities)
#ssh-add -l (lists the identities)

Now the benefits of having a passwordless svn:
- ofcourse it saves us a lot of time
- rails capistrano deployment

References:
http://www.howtoforge.com/debian_subversion_websvn

Subversion Tips and Tricks

http://subversion.tigris.org/faq.html#ssh-authorized-keys-trick

1. Checking out using svn+ssh and having passwordless ssh authentication. My personal favorite when working with personal projects since I have full control.

svn co svn+ssh://www.2rmobile.com/data/repos/web/rails/halalan2010 halalan2010

But for work projects, I normally use webdav

svn co "http://www.2rmobile.com/repos/web/halalan2010" halalan2010

2. svn+ssh on a custom or different port other than 22. I have my ssh on 2210, so we need to tell svn+ssh to use 2210

vim ~/.subversion/config
 41 [tunnels]
 42 ### Configure svn protocol tunnel schemes here.  By default, only
....
 53 ### built-in ssh scheme were not predefined, it could be defined
 54 ### as:
 55 ssh = $SVN_SSH ssh -p 2210

http://www.techper.net/2009/01/11/changing-port-number-of-svnssh-subversion-protocol/

3. svn diff – shows you the changes in a directory. This is useful for creating patches.

svn diff -r HEAD
svn st -q

3. svn switch oldURL to newURL - very useful when I’m working at home or in the office, since the svn server has a public/private IP.

4. svn log – shows you who committed and why (from the messages)

5. ignoring specific files in a directory. i.e rails directories

svn propset svn:ignore "*.log" log
subversion

iPhone Note #16: Creating a MKMapView using IB

Oct 29th

Posted by rupert in iphone

5 comments

In this tutorial we will be addking MKMapView using IB to a ViewController.

1. XCode -> File -> New Project -> View-based Application.

Name the project “SimpleMapIB”

2. Make sure everything works out accordingly before doing anything. Let’s test from the iPhone Simulator. Click on “Build and Go”. You should see the iPhone Simulator running with a gray background. Bring up the Debugger Console (XCode -> Run -> Console) as well and it should be free from errors.

3. Now double-click on “SimpleMapIBViewController.xib”, it should open in Interface Builder.

4. Drag a UIToolbar to the bottom. We will use the button as a GPS in our next tutorial.

5. Drag MKMapView to the middle of the screen.

6. IB -> save

7. Now we need to reference Mapkit. Go to XCode -> Project -> Edit Active Target “SimpleMapIB”. Click the + icon on the bottom left, choose MapKit.framework, then “Add”.

SimpleMapIB-1.png

You should see Mapkit added to the frameworks.

SimpleMapIB-2.png

You could also organize XCode’s left panel by dragging “MapKit.framework” to the Frameworks Group.

SimpleMapIB-3.png

7. Let’s code SimpleMapIBViewController.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
 
@interface SimpleMapIBViewController : UIViewController {
	IBOutlet MKMapView *mapview;
}
 
@property(nonatomic, retain) IBOutlet MKMapView *mapview;
 
@end

8. Now back to IB. Click on the “File’s Owner” and you should see your outlets displayed “Connections Inspector”. Drag “mapview” to MKMapView Control.


SimpleMapIB-4-sm.png

Note: You can click for a bigger image.

9. Now to set “SimpleMapIBViewController” as the delegate. Click on the MKMapView, it should be highlighted and in the “Connections Inspector” notice the “delegate” come out in the Outlets. Drag it to the “Files Owner” to set “SimpleMapIBViewController” as the delegate.

SimpleMapIB-5-sm.png
Note: You can click for a bigger image.

10. Now, let’s test. Hit “Clean All” then “Build and Go”. You should see something like this..

SimpleMapIB-6.png

11. Now to test that the delegate is setup accordingly, we can code on the viewDidLoad.

- (void)viewDidLoad {
    mapview.mapType = MKMapTypeSatellite;
 
	[super viewDidLoad];
}

12, Now press command-Y for “Build and Debug”. We should see a satellite map instead.
SimpleMapIB-7.png

13. That seems a little bit dull, lets add a segmented control so we can switch between maptypes (standard, satellite, hybrid). In IB, drag a UISegmentedControl in the UIToolbar at the bottom. Add another segment, making a total of three. Then change the titles to “Normal”, “Sat”, “Hybrid” respectively.

SimpleMapIB-8.png.

14. Let’s code. In the interface, we need to add a method that would be called by the segmentedControl whened the values changed.

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
 
@interface SimpleMapIBViewController : UIViewController {
	IBOutlet MKMapView *mapview;
	IBOutlet UISegmentedControl *segmentedControlMapType;
}
 
@property(nonatomic, retain) IBOutlet MKMapView *mapview;
@property(nonatomic, retain) IBOutlet UISegmentedControl *segmentedControlMapType;
 
- (IBAction)changeMapType: (id)sender;
 
@end

Now in IB, click on the “File’s Owner” and you should see your outlets displayed “Connections Inspector”. Drag “segmentedControlMapType” to the segmented control just like what we did for mapview.

15. In the implementation, we can switch between the segmentIndex and display the corresponding MKMapType.

- (IBAction)changeMapType: (id)sender{
	if(segmentedControlMapType.selectedSegmentIndex == 0){
		mapview.mapType = MKMapTypeStandard;
	}
	else if(segmentedControlMapType.selectedSegmentIndex == 1){
		mapview.mapType = MKMapTypeSatellite;
	}
	else if(segmentedControlMapType.selectedSegmentIndex == 2){
		mapview.mapType = MKMapTypeHybrid;
	}
 
}

16. Now to hook the IBAction of the UISegmentedControl to the method. In IB, click on the segmented control and in the “Connections Inspector”, drag the “Value Changed” Event to the “File’s Owner” and choose “changeMapType”.

“>SimpleMapIB-9-sm.png

17. Now test in the simulator again and the hybrid button should work.
SimpleMapIB-10.png

Download SimpleMapIB.zip

In my next tutorial, I would be hooking up a GPS button which handles location updates using CoreLocation.

iphone

iPhone Note #15: Omnigraffle iPhone Stencils, Screen Mockups via PPT, creating an iPhone interface before actual development

Oct 20th

Posted by rupert in Uncategorized

No comments

stencil.gif

I can not argue enough how valuable an iphone stencil will be in seeing the overall design/flow of an application. I should have done this a long time ago.

Well, I am also one of those eager developers who dives right into coding and see how it goes. But after having the fundamentals of iphone development, objective-c, and app-store submission, I’m taking on a different approach by creating screen mockups mainly for the following reasons:

1. Reach out quickly to the client.

2. Provides a bird’s eye view of the whole application. Provides alternative screens for a better user experience..

3. A follow up on the screen mockups is a powerpoint with actual links to other slides thus mimicing an iphone interface. Note, it is not a complete replica of the simulator but just enough for decision makers to understand what’s in there.

stencil-ppt.jpg

In powerpoint, you can just quickly overlay a transparent polygon on top of the UIButton then attach a hyperlink to another slide.

Hope this post helps you even if it’s not related to coding. On my next post, which is currently buried in my drafts–hopefully it will not be that long, I learned about integrating with Mobile Advertising Networks.

iphone

UPDATED: Bayanihan iPhone Project for Ondoy. Submitted.

Oct 5th

Posted by rupert in Personal

No comments

I am a programmer currently in Melbourne, Australia hoping to raise awareness for the victims affected by typhoon Ondoy (Ketsana-international name). Experiencing a flood is not new to me as I was born and raised in Tumana, Marikina, Metro Manila. I was in primary school, when I could vividly remember my mother cooking and serving porridge to typhoon victims as our backyard was called “high ground” since it is near the main road (JP Rizal).

I was in college when Tumana bridge was built and helped me travel from my house to the University. Unfortunately, the river would swell and the flood would swallow the whole bridge after 2-3 days of rain. I called my mother on Sept 27 and was informed the typhoon poured over a whole month of rain in just a few hours! Don’t worry my mother is fine, however, there are those who are unfortunate enough who desperately call for our help. In my small way by making this application, I would like to show my support for them.

I’m almost finished with the Bayanihan iPhone project which I worked on over the weekend. It is a very simple app with scrollable images. The server side is almost finished and would display how many supported/downloaded the application in real time. I am hoping to upload the server side to my Linode hosting in the US asap.

How can you help? I need pictures! Pictures from Tumana would be greatly appreciated, however, if you have other pictures, please do send them as well. I will be bundling 10 pictures inside the application. Please include your name, with subject: BAYANIHAN pix and send the pictures to my email address: rndguzmanjr@gmail.com

Hopefully I can submit the app to Apple within this week or early next week. Afterwards, we wait for the approval process within 2 weeks. Note, the app would be FREE.

UPDATE OCT-05-2009 9:00PM
I took some pictures from facebook and dropped it in the project. It would look something like this when it is finished.

bayanihan-sample-1-small.jpg

UPDATE OCT-11-2009
- Included proper credits for each photograph.
- Added Admob.
- Created logo, large application icon.

Icon.png

UPDATE OCT-12-2009
Preparing for appstore submission..

UPDATE OCT-13-2009
Submitted in AppStore. Currently, In-Review.

0.jpg

8.jpg

iphone
«12345»102030...Last »
  • Tags

    Algorithms apache centos china coldfusion coldspring debian eclipse ExtJS firefox gdal GeoJSON google iphone javascript lbs leopard linux mac mapinfo mapserver modelglue mod_python mysql ogr2ogr openlayers oracle pgRouting postgis postgres python qmail raster reactor routing ruby ruby on rails sqlite3 subversion svn tilecache trac uml windows mobile WordPress
  • Recent Posts

    • iPhone Bug Note #1: Route-Me and Three20 in the same Project. _aasin dup symbol when building on iOS4
    • iPhone Dev Note #21: Route-Me Offline Mapping from Database
    • What I’ve learned during the past two weeks (July 26 – Aug 8) in iOS Development?
    • iPhone Note #14: Drawing a Point, Line, Polygon on top of MKMapview
    • iPhone Cross Application Launch/Marketing Strategy
    • Blogging, MyTravelPhilippines, Navteq
    • Rails Note #14: QuickStart Tutorial
    • iPhone Note #20:Integrating Mapserver/TileCache to RouteMe
    • iPhone Note #19: Route-Me: Opensource mapping for the iphone
    • iPhone Note #18: Integrating Ads (AdMob) on your iPhone App
  • Comments

    • Yetlqlfu on OpenLayers + Google Spherical Mercator Example
    • Ttpmbvlx on OpenLayers + Google Spherical Mercator Example
    • Wzawcoam on OpenLayers + Google Spherical Mercator Example
    • Nmhmmwsv on OpenLayers + Google Spherical Mercator Example
    • Urepghgc on OpenLayers + Google Spherical Mercator Example
  • Archives

    • August 2010 (4)
    • July 2010 (2)
    • February 2010 (1)
    • January 2010 (1)
    • December 2009 (2)
    • November 2009 (2)
    • October 2009 (3)
    • September 2009 (4)
    • August 2009 (13)
    • July 2009 (1)
    • June 2009 (2)
    • May 2009 (2)
    • April 2009 (1)
    • December 2008 (4)
    • November 2008 (18)
    • October 2008 (2)
    • September 2008 (6)
    • August 2008 (7)
    • July 2008 (6)
    • June 2008 (3)
    • May 2008 (9)
    • April 2008 (2)
    • March 2008 (9)
    • February 2008 (7)
    • January 2008 (7)
    • December 2007 (2)
    • November 2007 (8)
    • October 2007 (3)
    • August 2007 (16)
    • July 2007 (13)
    • June 2007 (11)
    • May 2007 (1)
    • April 2007 (5)
    • March 2007 (5)
    • February 2007 (9)
    • January 2007 (12)
    • September 2006 (5)
  • Useful Links

Mystique theme by digitalnature | Powered by WordPress
RSS Feeds XHTML 1.1 Top