How to reset UIWebView's zoom?

In iOS, the UIWebView component is composed of an inner UIScrollView and a web container. In older versions of iOS (4.3) the internal ScrollView is not visible, but we can access it. 

Reset the zoom is a big question especially when you want to do programmatically. In my research I concluded that the best way is as follows:

Show Maps on iOS (iPhone / iPad) - the right way

Ok. yeah, Google Maps App shows maps on iOS but not only show the maps we need.  we need to:
  • Embed the map in an iOS App
  • Interact with the embedded map
  • Geolocalize on the map
  • With different maps sources
  • Offline maps
  • Cook cakes. not it is not necessary
well, we have alternatives:

MKMapKit:
Cocoa Touch Library included in iOS SDK. it provide some classes that interact with maps and geolocalization. the main class that we need is MKMapView, this class implements  the Google Maps API natively.

  • Embed: YES
  • Interaction: YES
  • Geolocalization: YES
  • Different sources: NO
  • Offline maps: NO
but google maps and MKMapKit not are the whole,


Route-Me: (https://github.com/route-me/route-me)

Is an iOS Map Library, entirely open, and works with any map source.

  • Embed: YES
  • Interaction: YES
  • Geolocalization: YES
  • Different sources: YES, Bing Maps, CloudMade, Spatial Cloud, OAM, Open Street Maps.
  • Offline maps: YES, MBTiles, DBMap
How it works?
  • You need to define a Tile Source
  • Instantiate a RMMapView (that shows the map)
  • Instantiate a RMMapContents with the source and view
  • interact with the map
This sample interact with CloudMade:

Media_http3bpblogspot_beadu

I said ¿Offline?

MBTiles:
Is an offline map source spec, allow to store map information in a SQLite database. more information at: https://github.com/mapbox/mbtiles-spec   

Route-Me and MBTiles together:

Media_http2bpblogspot_tfhgn

iPhoneSim

Since one month ago i started to develop over Titanium Mobile to build mobile applications more quickly, easy to share, and easy to coding. But many problems occurs when you have many iOS Sdks in your system. Basically when Titanium try to launch iphone simulator, it uses an binary called "iphonesim", this binary uses the "default" SDK directory: "/Developer".  I deleted the Linker Flags at the project file to  build without the strong reference.

You can use this tool well:

Where:
simulator_path is the path on you have installed the simulator (ex: "/Developer3.1/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/iPhoneSimulatorRemoteClient.framework/Versions/A/")
iphonesim is the path of this binary

You can use this binary and source from https://github.com/continuum/iphonesim

Titanium Mobile

Titanium is a framework (Open Source Framework) to enable cross-platform development. you can develop an application that runs on Mobile devices (iOS, Android, RIM) or Desktop platforms (OSX, Windows).

The application's source is written all in Javascript, CSS and HTML5. It's Great!! because you no need learn complex languages like Objective-C or C++.

how I start? http://developer.appcelerator.com/get_started

Titanium is Extensible, You can extend the framework adding your owns modules in objective-C or Java (android). http://developer.appcelerator.com/apidoc/mobile/latest/Titanium-module

Exists a lot of documentation: http://developer.appcelerator.com/doc/reference_guides

With Titanium you can taking advantage of Native Interfaces:

Media_http2bpblogspot_iiebj

Multimedia applications:
Media_http2bpblogspot_iomjc

Mobile and Desktop
Media_http3bpblogspot_bmbfl

Javascript language

<script src="http://pastie.org/1342073.js"></script>

How is it Possible???
Titanium has a bridge, which translates the javascript code with the equivalent Objective-C - Java Code at runtime.

Media_http3bpblogspot_badsm

Objective-C - Instrospection (part two)

In Objective-C an "Protocol" define the behavior of a class, like a Java Interface.

How I do check if the object implements an interface (<protocolame>?
[object conformsToProtocol:protocolname>];

Check if the object is an instance of a class <classname>
[object isKindOfClass:@"classname"];

Check if the object implements a specific method <methodname>
[object respondToSelector:@selector(methodname)];
or
[object respondToSelector:@selector(methodname:)]; //method with parameters

Invoke a method <methodname> dynamically:
[object performSelector:@selector(methodname) withObject:anyobject afterDelay:seconds]


Objective-C - Instrospection

I developed an application that consume http response in JSON format. My goal is parse this JSON response and deserialize ein domains objects or array of domain objects. But it is simple when you know the response and the correspondient domain object to utilize, however when it is not known it's very dificult.

I built an fragment of code that use instrospection and parse an xml (configuration file) that contains the "Service Location", "Name of the domain Class", the "remote field" and the "local property".

The JSON Response:

<script src="http://pastie.org/1335180.js"></script>

The XML Configuration File

<script src="http://pastie.org/1335172.js"></script>

The Domain Class Menu.m

<script src="http://pastie.org/1335165.js"></script>

The Code

<script src="http://pastie.org/1335169.js"></script>

Note:
* [serviceConfig objectForKey:@"key"] get the element at Configuration File.
* [responseBody JSONValue] get the JSON result (parsed into dictionary)

1. at the row 8 the sentence [[[NSClassFromString(outputClass) alloc] init] autorelease]; makes a instance of class (with name in outputClass string variable). This object, result, of type "id", is the domain object.

2. [result valueForKey:[output objectForKey:@"local"] get the class attribute "local", if not exist return nil.

3. The method isKindOfClass:[NSNumber class]] verify if the class of the local attribute "local" is NSNumber

4. [result setValue:[rawResult objectForKey:[output objectForKey:@"remote"]]
forKey:[output objectForKey:@"local"]]
it is the most important sentence. use the Key-Value feature of objective-C to assign dynamically a value to a Property.