Simple Ajax script for iphone? - iphone

How do you use an ajax script on an iPhone app?
I have a jquery script on my webpage that i would like to be on the view controller for my new app.
<jquery...code...>
Lets pretend the above is the jqueury code. How would i port this over to the iPhone view controller? Thanks sorry the question is so simple.
(all the code does is display a loading box that spins around and around and its quite pretty. Im probably going to put an image inside it )

Unless you're using a UIWebView in which case you simply embed a web page (including the JS code) into your app, jQuery (or rather Javascript and the DOM) is completely distinct from Objective-C and Cocoa Touch, so you can't use it, and the only option is to rewrite the same code in the new language and framework.

Related

HTML5 ui-controls pick up from canvas-1 and drag-and-drop onto cnvas-2

I am very new to web based programming and have started with HTML5 from this week.
I have create a bunch of flow-chart diagrams on first canvas-1 programmatically by javascript and by using addflow (Lassange) HTML5 controls. Now I have another canvas-2 at its side on which I want the user to pick any given UI-control (from canvas-1) and drag-and-drop the same on canvas-2. BUT I am unable to achieve this.
I tried assigning draggable property to the programmatically created ui-control (canvas-1) and also made the canvas-1 draggable etc but I think this approach will not work. The UI-control does get dragged but ONLY within the boundaries of canvas-1. Now how do I ensure that an user can be able to do this... what should be my javascript coding approach at the html-page-behind?.
EDIT: Somebody who is acquainted with Lassalle's technologies -- 'AddFlow' HTML5 jscript component can be of more help here because I am using that HTML5 control to create two canvas and for filling the set of UI-controls as a 'pallet' into the canvas-1. But if somebody has achieved this through some native HTML5 javascripting or alike then still do reply.

Javascript and objective c

I want to show a popover view on top of a webview. And the popover should be shown on selecting any UI element in webview. I am able to capture the touch event in a Javascript code . Can anyone help me.. Is it possible to post a notification event from the Javascript..? Is there any other way of achieving this..?
Thanks.
This is exactly what PhoneGap does. The idea behind it is that in response to the touch, your JavaScript loads a particular URL, possibly with a custom scheme. The web view delegate's -webView:shouldStartLoadWithRequest:navigationType: method is called before the web view actually makes the request. If the implementation of that method recognizes the URL, it can then take whatever action it likes, such as displaying a popover view.
You can easily call your scripts (with in the sandbox) from your objective-c methods. Thw Web kit has the methods for evaluating Script codes [webview stringByEvaluatingJavaScriptFromString:#"myJavascriptFunction()"];Check this tutorials to learn dig deeper Tutorial-1 and Tutorial-2.. hope this helps you...

Create springboard like main view

Is there some sample code, or an easy way, to implement an application with as its first view something like Springboard?
What I am looking for is just a view with basic icons which after a tab on an icon tells the view-controller to push the view associated with the selected icon.
This in itself is not that difficult off-course (just putting images on a view), but is there an easy way to implement all the extra functionality as well (as e.g. moving the icons around (start 'vibrating' when when you push hold them), multiple pages etc.). The Facebook App seems to have this. It is probably not worth my while to write it myself, but it would be nice if there is something 'out of the box' to give the App a bit more of an iPhone feel.
Thanks in advance!
Facebook uses the Three20 library for its UI. The specific view used for the SpringBoard-like interface is known as TTLauncherView.
This is not an endorsement (I have yet to really check this out, and I may be too entrenched in using Three20 at this point to even bother), but here is another project that implements the springboard functionality: myLauncher on Github
You can use UICollectionView to create this
Look at this example
https://github.com/tularovbeslan/Springboard

How to implement iPhone TitleBar in Android

You know in iPhone, The four components of a typical iPhone application are
a title bar,
a navigation list,
a destination page,
and a button bar.
for The Title Bar
The title bar includes the following elements:
Back button:
Screen title:
Command button:
My question comes, although i can use UI framework tool, such as:
Phonegap,
iui,
jtquery
to develop web app, but i can't display the TitleBar effect in Android,
i can't use below code in Android:
meta content="yes" name="apple-mobile-web-app-capable"
Actually, the above can work in Apple Safari Browser, but I can't use Safari to display our Android Project, which is i don't want to see.
Does anyone know how to fulfill this effect in Android, please help me, your help will be great appreciated.
to
"It's unclear if you developing a native android application or a webapp.
– alexanderblom yesterday"
sorry that i forget to mention, i want to develop a iphone-webapp-style application in Android. Since it's too difficult, i want to use iWebkit, but it seems only work in apple iPhone OS or Safari which contain the specific engine to display the beautiful layout, like below:( -_-! i am new so i can't post images here)
(source: appshopper.com)
If I'm not mistaken, if you want to custom in any way the title bar at the top of your screen, you have to do several things :
First, read this thread about titlebar customisation, as it's quite detailled.
Then, you have to add a few more things to it to match your requirements, all in the same xml file which will be your titlebar.xml:
-a button, on which listener you assign the same keyEvent as the normal back key of every android phone.
-a textview for whatever title you want to put in.
-a button for the command button, for whatever it does in Iphone (if you tell me what it does, maybe i'll be able to give more details)
Then, as I take it, you want to have it available on all your pages, without having to request titlebar customization on every activity, I would recommend you to use the same trick as I did : Define a superclass, which all your activities will extend.
then you you requestwindowfeatures in this class, and do all your customization in this one.Finnaly, You just have to call the variable of your titlebar textview in the oncreate of all your subclasses to assign the string you want on each page. If your string is generated dynamically from, lets say a file name you load from the internetv in a background thread, you will need to define a handler to the main thread as you can't update a view from another thread than the one that has created it.
Hopes that helps. If you have any question about that, feel free to ask, i'll keep an eye on your topic, because I had quite a pain to make my titlebar work properly.
good luck

How to set focus on textarea of html using objective c/ iPhone

I am using this code to set the focus on textarea of HTML control using javascript in objective c.
But its not working in UIWEBVIEW, while other code working for getting values of the html controls with same controls ID.
here the code:
it is working
NSLog(#"m values %#",[webView stringByEvaluatingJavaScriptFromString:#"document.getElementById('2txt').value"]);
it is not working:
[webView stringByEvaluatingJavaScriptFromString:#"document.getElementById(\"2txt\").focus();"];
Any Idea,
Thanks,
When / from where are you executing the call to focus on the page element? If you're doing the focus first thing (as a UI setup when the page is loaded), are you first checking to make sure the page has loaded in its entirety? The element may simply not "be there" yet when you're trying to focus it.
This is purely a guess. :-)