Posts Tagged ‘iphone’

iPhone: How to display alert (message box) at iPhone using UIAlertView

Written by Alex on . Posted in Uncategorized

You can display alert message box on iPhone using UIAlertView class. The code below shows message box on iPhone:

-(void)showAlert
{
	UIAlertView *alert = [[UIAlertView alloc]
            initWithTitle:@"Hello from UIAlertView"
            message:@"UIAlertView was displayed"
            delegate:self cancelButtonTitle:@"Close"
            otherButtonTitles: nil];

	[alert show];
        [alert release];
}

Do not forget to release alert object after you dispalyed message box to the user.

iPhone: Required images to distribute application in App Store

Written by Alex on . Posted in Uncategorized

if you are going to distribute your application in Apple App Store, you have to create (or order from graphic designer) at least 3 images.

iTunes Artwork

This application should be send to Apple separate from your application. Apple use this image to create icons in iTunes. The size of image 512×512 pixels in PNG format. The file have to be named iTunesArtwork.png

Application icon

This image is an icon which will be available on iPhone device. The image size depends of iPhone model, for old iPhone devices it should be 57×57 pixels, but for iPhone 4 it should be 114×114 pixels (but from our experience small 57×57 icons works find on iPhone 4). The file name should be Icon.png

Launch image

Launch image is the last required image for iPhone device. The size of image should be 320×480 pixels and the file name should be Default.png

All images should not contain rounded corners, because iPhone do it for you. Just create 90 degree corners.  If you already applied shine effects, let your programmers know it. When you do not let the iPhone/iPad OS to apply the gloss to your icons, developers must add a key to info.plist called UIPrerenderedIcon and make it checked.

Optional and required images for iPhone and iPad

Below there is a table which contains the list of all images, optional and required for distribution application in Apple App Store.

Name Size (pixels) Platform
Icon.png 57 x 57 Universial application icon
Icon-settings.png 29 x 29 Universial application icon for settings area. Alternative name: Icon-Small.png
Icon~ipad.png 72 x 72 iPad application icon. Alternative name: Icon-72.png Add some smaller (iPad doc: 64×64, other optional 32×32, 24×24, 16×16) custom icons to your project. See comments.
Icon-spot~ipad.png 50 x 50 iPad icon for spotlight search. Alternative name: Icon-Small-50.png iPhone OS trims 1 pixel from each side and adds a drop shadow. The actual size is 48×48 pixels.
iTunesArtwork.png 512 x 512 Universial application icon for iTunes App Store. Uploaded separately to iTunes. It is included in the app bundle too, file name: iTunesArtwork. In an iPad application iPhone OS uses this image to generate the large (320×320) document icon if it is not supplied otherwise.
Default.png 320 (w) x 480 (h) iPhone/iPod 2, 3 portrait launch image
Default@2x.png 640 (w) x 960 (h) iPhone 4 hi-res portrait launch image
Default~ipad.png 768 (w) x 1004 (h) iPad. Specifies the default portrait launch image. This image is used if a more specific image is not available. Use full size template (768×1024) to design this launch image. The 20 pixels height statusbar is on by default and occupies the top of the screen, aka the 1004 rows vs. 1024.
Optional icons and images:    
Icon@2x.png 114 x 114 iPhone 4 hi-res application icon
Icon-settings@2x.png 58 x 58 iPhone 4 hi-res application icon for settings/search area
Icon-doc.png 22 (w) x 29 (h) Universial document icon
Icon-doc@2x.png 44 (w) x 58 (h) iPhone 4 hi-res document icon
Icon-doc~ipad.png 64 x 64 iPad document icon (small)
Icon-doc320~ipad.png 320 x 320 iPad document icon (large)
Background-xxx.png 320 (w) x 480 (h)
640 (w) x 960 (h)
768 (w) x 1024 (h)
iPhone/iPod Touch 2, 3 background image,
iPhone 4 background image, full size
iPad background image, full size. For most projects the status bar is hidden, so use full screen size by default.
Default-PortraitUpsideDown~ipad.png 768 (w) x 1004 (h) iPad. Specifies an upside-down portrait version of the launch image. The height of this image should be 1004 pixels and the width should be 768. This file takes precedence over the Default-Portrait.png image file for this specific orientation.
Default-LandscapeLeft~ipad.png 1024 (w) x 748 (h) iPad. Specifies a left-oriented landscape version of the launch image. The height of this image should be 748 pixels and the width should be 1024. This file takes precedence over the Default-Landscape.png image file for this specific orientation.
Default-LandscapeRight~ipad.png 1024 (w) x 748 (h) iPad. Specifies a right-oriented landscape version of the launch image. The height of this image should be 748 pixels and the width should be 1024. This file takes precedence over the Default-Landscape.png image file for this specific orientation.
Default-Portrait~ipad.png 768 (w) x 1004 (h) iPad. Specifies the generic portrait version of the launch image. The height of this image should be 1004 pixels and the width should be 768. This image is used for right side-up portrait orientations and takes precedence over the Default~ipad.png image file. If a Default-PortraitUpsideDown.png image file is not specified, this file is also used for upside-down portrait orientations as well.
Default-Landscape~ipad.png 1024 (w) x 748 (h) iPad. Specifies the generic landscape version of the launch image. The height of this image should be 748 pixels and the width should be 1024. If a Default-LandscapeLet.png or Default-LandscapeRight.png image file is not specified, this image is used instead. This image takes precedence over the Default.png image file.

iPhone can’t find SQLite database but simulator can

Written by Alex on . Posted in Uncategorized

Now our company working on iPhone application to track weight. The application user SQLite database as a data source for weight values.

We tested application on iPhone simulator and it worked fine, it was no problems with opening database, reading and writing records in SQLite database.

But after deployment on iPhone device application stop working. For some reason application was not able to find database on iPhone device.  Googling and asking questions on StackOverflow did not helped, and our developer continue investigate around this issue.

And finally the problem was solved. It was small defect in our application with upper and lowercase names.

The difference between iPhone device and iPhone application was the following: iPhone cares about register of filenames, but iPhone device does not care. So the name “database.sqlite” and “Database.sqlite” was different files on iPhone device.

As we understand later it’s a normal behaviour for UNIX system, but for developers who come from Windows it’s a little bit weird behaviour.

iPhone: open connection with SQLite database

Written by Alex on . Posted in Uncategorized

To open connection with SQLite database from iPhone you need to follow the steps: At first you have to add reference to SQLite framework in Xcode project. If you using Xcode 4 go to “Target” -> “Build phases” and under “Link binary with libraries” add “libsqlite3.dylib” file. After you have reference to SQLite framework include header file at the top of your code file.

	#import <sqlite3.h>

Now you can use SQLite functions in your code.

Open connection with SQLite database

You can open connection to database using the following function

int sqlite3_open(
  const char *filename,   /* Database filename (UTF-8) */
  sqlite3 **ppDb          /* OUT: SQLite db handle */
);

SQLite API have two more function to open database, but this is the simplest. If you need to read more how to open connection from iPhone application to SQLite database refer to SQLite documentation.

Usually you have database name as a (NSString*) variable, so you have to extract UTF8 string from NSString. You can do it using UTF8String method.

This is an example from iPhone application which we recently developed:

	// databaseFullPath was defined in different place,
	// and contain path to SQLite database file
	sqlite3 *database;
    if(sqlite3_open([databaseFullPath UTF8String],
	&database) == SQLITE_OK)
    {
		// database is opened. you can read/write to database

		// do not forget to close database
		sqlite3_close(database);
	}

If sqlite3_open function returns 0 or SQLITE_OK, it means than database was found, and connection was successfully opened. Otherwise something happened during the opening. Most probably database file was not found.

iPhone: Core-plot plotting framework labels overlapped

Written by Alex on . Posted in Uncategorized

For our iPhone weight tracking application was opened a defect: “labels overlapped when user zooms graph”.

For displaying graphs in iPhone application we use Core-Plot plotting framework, which is a great for displaying charts, graphs… in iPhone applications.

By default when user opens a graph it displays around 10 past records, but when user start zooming out the graph, more and more records need to be displayed. And at the end the graph looks like below. The x axis contains too many labels and they are overlapped.

core-plot-labels-overlapped

After some digging around, the solution was found.
Both X and Y axis have properties labelingPolicy which can have one of the following values

    CPAxisLabelingPolicyNone,	 ///< No labels provided; user sets labels and locations.
    CPAxisLabelingPolicyLocationsProvided, ///< User sets locations; class makes labels.
    CPAxisLabelingPolicyFixedInterval,	 ///< Fixed interval labeling policy.
    CPAxisLabelingPolicyAutomatic	 ///< Automatic labeling policy.
	

To make labels displays automatic, depending on scale, the labelingPolicy property has to be set to CPAxisLabelingPolicyAutomatic value
Also developer has to setup property preferredNumberOfMajorTicks which defines how many labels will be displayed for X or Y axis, in our case it’s 10. After the fix was done, graph looks like below

core-plot-lables-are-not-overlapped

 

As you can see labels are not overlapped now and if user zoom in or out the graph, the labels will be automatically adjusted, so only ten labels will be displayed.

Loosing weight just got easier with the new “Weight Tracker” iPhone application

Written by Alex on . Posted in Uncategorized

We just released the iPhone’s new weight tracking application: “Weight Tracker” It is now officially available for download from the Apple App Store.

Weight Tracker” helps users meet their diet and weight loss goals. With it, users can monitor their weight on a daily basis, and use a helpful graph to track their weight loss progress.

Some of the application’s key features include:

  • Touch-sensitive graph, which can be dragged onto screen and resized
  • Visual display of weight-loss progress
  • Informative list detailing your previously recorded weights
  • Ability to enter any past weights
  • Ability to delete old weights
  • No registration required
  • Supports both Landscape and Portrait views

 

The application is free to use and is available at the Apple App store, at the following link: http://itunes.apple.com/us/app/weight-tracker-by-yaplex/id452492644 Support and more information can be found at the support website (http://yaplex.com/)

Unlike other applications at the Apple App Store, Weight Tracker does not require any registration. Users can simply download the app and get started!

 

 weight-monitor-weight-tracking-graph-1    weight-monitor-remove-weight-2

Do not forget to give five stars to application at Apple App Store