Monday, July 23, 2012

How to Play, Record, and Edit Videos in iOS

This is a blog post by iOS Tutorial Team member Abdul Azeem, software architect and co-founder at Datainvent Systems, a software development and IT services company.
Recording videos (and playing around with them programmatically) is one of the coolest things you can do with your phone, but surprisingly relatively few apps make use of it.
This is likely because learning the technology behind video recording and editing in iOS – AVFoundation – is notoriously difficult.
And to make it worse, there is very little documentation on how to accomplish anything with AVFoundation. One of the few resources available is the WWDC 2010 AVFoundation session video, but it only takes you so far.
There should be an easier way. Thus was born this tutorial! :]
In this tutorial, we’ll give you hands-on experience with the AVFoundation APIs so you can start using them in your own apps. You’ll learn how to:
  • Select and play a video from the media library.
  • Record and save a video to the media library.
  • Merge multiple videos together into a combined video, complete with a custom soundtrack! :]
Are you ready? Lights, cameras, action!

How To Write A Simple PHP/MySQL Web Service for an iOS App

As an iPhone/iPad developer, it can be really useful to be able to write your own simple web services that integrate with your apps.
For example, you may wish to display some news updates that come from your web server, and display it on startup. Or perhaps store some user data “in the cloud”. Your imagination is the only limit!
In this first tutorial in this two-part series, you’ll go step-by-step through the process of creating a simple web service, based on a promo code system I included in my latest app, Wild Fables. In the next part of this series, you’ll write an iOS app that integrates with this web service!
To run through all of the steps on this tutorial, you’ll need a web server with MySQL and PHP. If you do not have a web server already, you have three options:
  • If you want to enable Apache/MySQL/PHP directly on your Mac (for free), there are lots of good guides out there, here’s one I found with a quick Google search.
  • If you want to rent a web server online (usually for $$), there are many good choices out there, but the one I personally use (and enjoy) is Linode – check this tutorial for more information.
  • And if you’re just too lazy to do either of the above, you can just read through the steps below, and use the web service I’ve already made in part 2 of series :]
You don’t necessarily need to know PHP or MySQL to go through this tutorial (although it will be helpful!), as the tutorial includes all of the code you’ll need.

Wednesday, July 18, 2012

How To Create A Simple iPhone App in iOS 5 Tutorial: Part 3/3


This article is the final part of a 3 part series on how to create a simple iPhone app for beginners. And this app happens to be about rating scary bugs!
In the first part of the series, we created an app that contained a list of bugs in a table view.
In the second part of the series, we covered how to create a detail view for the bugs.
In this article, we’ll cover how to add new bugs, how to add an icon and default image to our project, and how to handle long-running operations.
So let’s wrap this app up!

Adding and Deleting Bugs

Everything’s working great so far, but so far this isn’t a very user-friendly app! I mean the first thing anyone would want to do is add their own bug, and so far the only way to do that is by editing code!
Luckily, since we wrote our DetailViewController to allow editing of bugs, and are using a UITableViewController for the RootViewController, most of the infrastructure is already in place! There are just four changes we have to make, but I’m going to explain them bit-by-bit to keep things easy to understand:

How To Create A Simple iPhone App on iOS 5 Tutorial: Part 2/3


This article is the second part of a three-part series on how to create a simple iPhone app for beginners. And this app happens to be about rating scary bugs!
In the first part of the series, we created an app that contained a list of bugs in a table view.
In this second article, we’ll cover how to create a detail view so that we can view a larger picture of the bugs, rate them, and and change their pictures!
In the third and final part of the series, we’ll cover how to add new bugs, add an icon and default image to our project, and handle long-running operations.

How To Create A Simple iPhone App on iOS 5 Tutorial: Part 1/3


The iPhone is an amazing platform to develop on for indie software developers. It’s never been easier to come up with your own unique app idea, code something up, and have it be available to millions of potential customers!
Lately I’ve been getting a lot of questions from people new to iOS development asking how to get started. So I thought it would be helpful to write a tutorial series tailored for beginners.
But rather than focusing in detail on just one topic, we’re going to dive in and create an entire functional app from scratch. By the end, you’ll have tried out many areas of iPhone development, and ready to dig in further.
So what’s the app we’re going to make? Well, there’s a story behind that…
The other night, I saw a picture of a Potato Bug for the first time and started freaking out because it was so big and ugly! Then I got obsessed with looking up all kinds of scary bug pictures online. So to spread the fun, we’re going to make an app for that – rating scary bugs!
While making this app, we’ll cover some of the most commonly used topics in iPhone development:

Wednesday, July 11, 2012

UITableView Tutorial

UITableView is one of the most common types of views used in iOS applications. Let’s go through a tutorial of the most regularly used features of table views.
There are two main types of UITableView. The first is a “plain” table view, which looks like this:
The second is a “grouped” table view, which looks like this:

Html form post in iPhone/iPad

this post tells how to make a html form post to web server and get back response from web server. I have used open source library ASIHTTPRequest library from ASIHTTPRequest .First download the library and add to your XCode project as mention in the site.

Now to post form data use below code:
NSURL *url = [NSURL URLWithString:@"http:webserveraddress"];
 ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
 [request addPostValue:@"test name" forKey:@"name"];
 [request addPostValue:@"test addr" forKey:@"addr"];
 [request setDelegate:self];
 [request startSynchronous];

Lazy loading Custom UITableViewCell

this tutorial says how to lazy load or Asynchronous load custom table cell image so the scrolling of table cell is efficient.i have taken help from  apple’s sample code for lazy loading or asynchronous loading and use for custom table cell.
first crate view controller and create table view as the way you want, i have created view controller and added table view.Now in view controller ,since we are requesting to url for our data ,make NSURLConnection as below
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:xmlDataUrl]];
self.connection = [[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self] autorelease];
since we have set delegate of connection to self to it will return to following method after data is loaded.

Sunday, July 8, 2012

iPhone JSON Flickr Tutorial – Part 3

In this tutorial we wrap up by adding a simple image viewer that will display a larger variation of the image when the user taps on a row in the table. We’ll add some code to slide the larger images on/off screen, which is a nice visual effect for this application. You can review the finished application by watching the video below:


Download iPhone JSON Xcode Project
You can download the Xcode project and walk through the source code:
  1. Download iPhone, JSON and Flickr – Part 3 Xcode project

iPhone JSON Flickr Tutorial – Part 2

Download iPhone JSON Xcode Project File
You may find it helpful to download the Xcode project and walk through the source code as you read this tutorial.
  1. Download iPhone, JSON and Flickr – Part 2 Xcode project
Flickr JSON Data
Let’s begin by taking a closer look at the data returned from Flickr and the resulting dictionary that the JSON framework creates for us.
The method that we wrote in Part 1 for receiving date from Flickr, didReceiveData, begins with the following two lines:

iPhone, JSON and Flickr Tutorial – Part 2

JSON is most commonly used as an alternative to XML for RESTful style web services. As such any example that demonstrates anything about JSON must first begin with an example of how to download JSON data.
Let’s begin by creating a method called stringWithUrl: that will download data from a specified URL and return the data as an NSString

iPhone JSON Flickr Tutorial – Part 1

Two consistently popular posts on are iPhone JSON Frameworks for iPhone Part 1 and Part 2. Seems a good time to revisit the combination of the iPhone and JSON, this time creating a complete working application.
This is part one of a three part series in which I’ll build a Flickr photo viewer, a pretty simple application, however, we’ll cover some interesting stuff with the primary goal of understanding the nuts and bolts of working with JSON to build a complete working application accessing web-services.
Let’s start by looking at the finished application – the video below shows the end result we’re after – it starts with a search box (UITextField) and an empty table. Once you enter a search string, the application will construct a URL to call a photo search method at Flickr. The return data will be used to populate a table with thumbnails images and any title associated with the photo.

Showing Network Activity When there Isn’t Any

I found that sometimes you may be doing something in your iPhone application that requires the user to wait while it completes. Often this is a network related activity, but in other cases it may not be. In my case I was parsing the response from a network connection and wanted the network activity indicator to keep spinning even though it had already downloaded the content.

Here is a quick tip on how to trigger the display of the network activity indicator (spinning icon at the top left of the screen) on an iPhone from within your application:

UIAlertView without Buttons – Please Wait Dialog

If you’ve ever wanted to show a simple “please wait” dialog without resorting to a custom view,UIAlertView is a good option, and is even more appropriate if you customize the alert such that no buttons are shown.
In the figure below you can see how a simple alert can be shown (sans buttons) while you are busy doing some other system activity (reading/writing files, etc).

UIAlertView Text, Secure Text and Login Password Input

In iOS 5, UIAlertView was updated to include support for text input, secure text input and login/password input. Say goodbye to the creative code (read hacks) many of us have tried, to add similar functionality.
The screenshots below show examples of each new alert style:

iOS 6 And Xcode 4.5 Beta 2 Now Available for Download

Apple has released iOS Beta 2. If you are developing applications using the latest iOS SDKs. you’ll want to download the new beta release.
In this release you’ll find:
- SDK updates
- Xcode 4.5 Developer Preview 2
- iOS 6 Beta 2 for installing on test devices

Yet Another Debug Output (NSLog Replacement)

Although NSlog is convenient for outputting messages to the console, I tire of the date/time and object information that it prints.
As an alternative, one can craft a macro that uses CFShow, which outputs Core Foundation objects to stderr. CFShow uses callbacks to objects to display their descriptions, which allows one to use “%@” like you would when calling NSLog.
I often include the following debug definition as part of my projects:
#define debug(format, ...) CFShow([NSString stringWithFormat:format, ## __VA_ARGS__]);

Write Debug Output to a File

NSLog definitely has its place in debugging. In a previous post I shared a version I wrote that skips displaying the date and object information, you can read more about the debug command I use on a regular basis here.
At some point, capturing debug statements to a file (versus the console) can be helpful to track down bugs. The good news is that you can continue to use NSLog (and/or the debug command from the previous post) by simply making a change to where stderr is directed.

Playing Sounds/Audio – Audio Session Services

If you need to play short sounds, less than 30 seconds, Audio Session Services are your friend. Here is a snippet of code to play a wav file:
SystemSoundID soundID;
NSString *path = [[NSBundle mainBundle]
   pathForResource:@"RapidFire" ofType:@"wav"];    
 
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path],&soundID);
AudioServicesPlaySystemSound (soundID);
For this to work, you will need to import <AudioToolbox/AudioToolbox.h> header file, and also add the AudioToolbox.framework to your project.

UIAlertView and Landscape Mode

I bumped into a rather odd UI issue early last week – I was working on an application which runs entirely in landscape mode. However, when I displayed an alert view, it came up as follows:

Changing Application Name on Home Screen

By default, the name of the application shown on the iPhone Home screen (below the icon) is the same as the project name. This will suffice in many cases, however, chances are the day will come when you’ll need to specify a different application name.
Changing the name is as simple as updating the Bundle Display Name in the info.plist file. By default this entry looks as follows:
Bundle Display Name: ${PRODUCT_NAME}
Simply replace the macro text with your preferred application name:
Bundle Display Name: Fubar
In my next post I’ll show you a trick to experiment with various names to see how they look on the Home screen, without having to go through the re-build, deploy cycle on your iPhone and/or the simulator.

Changing Views to Landscape Mode

As you well know, by default, iPhone applications launch in portrait mode. If you need to start your application in landscape mode, you can set UIInterfaceOrientation key in the plist file. The two possible values for this key are: UIInterfaceOrientationLandscapeLeft (iPhone home button will be on the left) and UIInterfaceOrientationLandscapeRight (home button on right).
For views to be shown in landscape mode, you must manually rotate the coordinate system 90 degrees. Here’s one way you can do that, let’s assume we have a class that is of typeUIViewController:

Play iPhone Movies in Portrait Mode with MPMoviePlayerController using Public API’s

Editor’s Note: With the release of SDK’s supporting 3.2 and 4.x, this approach is no longer necessary. The new movie player can now be displayed in either direction, landscape or portrait. Read this post for a more information: Display iPhone Movies in Portrait Mode (Updated)
It’s been covered by a number of websites and blogs on how to play movies in portrait mode using MPMoviePlayerController. Problem is, every solution that I’ve been able to find uses private API’s to tell the player to flip the direction of play.
Other than the built-in movie player, another option is to use a UIWebview, however, there are a few drawbacks including no support for notifications on when a movie has been preloaded, which is handy for displaying a “please wait” loading message.

Getting MPMoviePlayerController to Work with iOS4, 3.2 (iPad) and Earlier Versions of iPhone SDK

The API and overall approach for working with MPMoviePlayerController has changed just enough in the 3.2 SDK (iPad) and iOS4 SDK to cause working applications in earlier releases to be problematic when running on later SDKs. In this post I’ll walk through a short example of a movie player application that will work with 3.x, 3.2 and 4.0 SDKs.
In the next post, Display iPhone Movies in Portrait Mode, I’ll show how to create a movie player that runs in a view that is not fullscreen as well as how to show a few lines of code to display a movie in portrait mode – the one caveat here is that both of the tips in the second post will apply only to OS versions 3.2 and up.

Thursday, July 5, 2012

[J2ME] Send Text Message (Sms) using Wireless API

/* This example for sending sms using our SIM card.
Here im not using any PORT No to send the sms. so the received sms will be displayed in Inbox. This sms will be sent by using your sim card. so you will be charged for the same..*/

import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.wireless.messaging.*;
public class SendSms extends MIDlet implements CommandListener {
      Display display;
      private TextField toWhom;
      private TextField message;
      private Alert alert;
      private Command send,exit;
      MessageConnection clientConn;
      private Form compose;

Wednesday, July 4, 2012

PushRegistry, tự khởi động ứng dụng…

PushRegistry là gì??
PushRegistry chỉ có trong MIDlet 2.0
PushRegistry được dùng để cho phép ứng dụng tự động khởi động khi có một tác nhân bên ngoài tác động vào. Có 2 loại tác nhân ở đây là
1 Connection được thiết lập(Ví dụ: SMS tới chẳng hạn), loại thứ 2 là hẹn giờ, ví dụ hẹn đến 2h30 thì tự động khởi động chẳng hạn.
Ở đây tôi ví dụ với tác nhân thứ hai, tác nhân thứ nhất bạn có thể tự tìm hiểu. Đây không phải là một chuyên mục lớn nên tôi gợi ý,
các bạn có thể tự khám phá. Sau đây là Code của 1 MIDlet đơn giản ứng dụng PushRegistry.

J2ME - SMS

SMS là một trong những phát minh vĩ đại của con người, tính chất đó không những đúng trước kia mà bây giờ cũng vậy. SMS vẫn luôn là một tính năng rất tuyệt vời của điện thoại di động. Bạn không thể nói từ trước đến giờ bạn chưa bao giờ sử dụng SMS, chính điều đó đã chứng tỏ điều tôi muốn nói với các bạn. Hôm nay tôi xin giới thiệu sơ lược các thao tác cơ bản với SMS trên thiết bị di động.
Để có thể gửi và nhận SMS, bạn cần có một kết nối SMS(MessageConnection).
Có 2 loại: SMS server và SMS client. Dùng để gửi và nhận tin SMS.
Nói chung SMS server hoàn toàn có các tính năng của SMS client. Do đó ta nên dùng SMS server.
Khởi tạo SMS server:
MessageConnection msgCnn = (MessageConnection) Connector.open(“sms://123456:0001″);
=> Khởi tạo SMS server với số 12345 là tùy chọn và số này không quan trọng lắm, trường hợp cần thiết tôi sẽ nói sau. Và cổng của SMS server là 0001.
Cổng của MessageConnection là một điều hết sức quan trọng. Nếu gửi tin đi mà không có cổng thì thì tin nhắn đó sẽ giống như các tin nhắn bình thường và sẽ được trình nhận tin nhắn mặc định của điện thoại nhận và lưu trong hộp thư đến của máy. Trong trường hợp ta gửi có cổng(port) riêng thì tin nhắn đó sẽ được chương trình của ta tiếp nhận, tất nhiên là chương trình của ta phải có kết nối vào đúng cổng đó. Nếu không cũng chẳng có ai nhận SMS đó cả.

Popular Posts