Showing posts with label iphone. Show all posts
Showing posts with label iphone. Show all posts

Tuesday, September 20, 2011

Orientation changes for iPad - Secha & PhoneGap

I was working on a mobile application developed for iPhone. The application was built using Sencha Touch and PhoneGap. Its great what these guys have done to bridge the gap between Objective C and HTML/JavaScript/CSS. The application now wants to be run on iPad.

The orientation was something that caused a problem here. The call back for the orientation, onorientationchange, was not being called for some reason. I went through most of the content in the web which described the problem. Solutions were limited.

I tried putting window.onorientationchange, added event listeners for orientation and even added Objective C code ! Did not work ...

Thats when onWindowResize came into picture. The code started working. But just once. You change orientation and that works just once. The code goes something like :

var or = function(){ 
    // alert( Ext.getOrientation()); 
    var width = (Ext.getOrientation()=="landscape") ? window.innerWidth-1 : window.innerWidth; 
    panel.setOrientation( Ext.getOrientation() , width , window.innerHeight ); 
    panel.el.parent().setSize(width, window.innerHeight); 
    // return 0; 
    panel.doComponentLayout(); 

Ext.EventManager.onWindowResize(or);

The alert function caused a lot of issues for me. Firstly it creates an exception on the Objective C side. Signal Exception of some kind which says arguments are expected of a different kind. The setOrientation call is necessary for the panel to know the orientation. This did not update the width and height of the panel for some odd reason. So I did it manually by calling the setSize and to make sure I called the doComponentLayout.

Well, the code works now. This is for reference for all those people who have not still got the answers for this question.

Kudos !


Monday, April 7, 2008

The XCode IDE

The first demo of the Workstreamr app was given on Friday and Monday. Just before the Friday demo, Manish had a small announcement to make. To try to build a client, as the client we currently are building, that would run on an Apple iPhone. The reward would be an iPhone itself (so ha says) ! I, along with others were definitely interested. The browsed through the latest SDK that Apple had released for the iPhone and came to understand that the SDK needed a Mac for the development. That clearly justified my buying a Mac !!

I downloaded the SDK. A 1.3 Gb dmg file ! When installed, I found my XCode IDE overwritten with the new XCode version IDE which supported the iPhone development. I even downloaded podcasts with the Apple Evangelists giving excellent tips and tricks on iPhone based development. As I have only done development for the desktop, it was necessary to understand that it was not the same thing. Development in a phone which has memory and power constraints in tricky. The consistency and accuracy to be followed is extremely important.

I also came to know that the development language for independent apps in the iPhone was Objective C, a ANSI C based superset. The constructs are different and sometimes confusing. I like the part where messages are passed for method calls, it reminded me of Ruby. I am still trying to get in grips with this language for further development.

I was mesmerized by the development platform that Apple provided. XCode for app development, DashCode for web based development, Instruments for performance analysis. The iPhone development does not has the Interface Builder support yet but once it comes there no beating the toolkit.

Looking forward to some excellent programming on Objective C now !!!