Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Sunday, May 5, 2013

Icon sizes for iPhone & iPad


I decided to recompile some information about the sizes and names of the icons we need when we create an App.

Review of Icon Sizes

Image Description iPhone iPhone Retina Display iPad iPad Retina Display iPhone5
Application Icon Icon displayed on the device’s home screen, used to launch an application. 57x57 114x114 72x72 144x144 114x114
Settings Icon Icon used to identity an application in the iOS Settings Application. 29x29 58x58 29x29 58x58 58x58
Spotlight Search (uses same image as Setttings on iPhone) Icon used to identify an application in the Spotlight Search results. 29x29 58x58 50x50 100x100 58x58
iTunes Image Large image used by iTunes during ad hoc distribution. 512x512 512x512 512x512 512x512 1024x1024
Launch Image Image used as a placeholder screen while the application loads. 320x480 640x960 Portrait: 768x1004 Landscape: 1024x748 Portrait: 1536x2008 Landscape: 2048x1496 640x1136

iPhone Launch Images

Device Target File Name Size (in pixels)
iPhone 3GS Default.png 320x480
iPhone 4 Default@2x.png 640x960
iPhone 5 Default-568h@2x.png 640x1136

iPad Launch Images

File Name Size (in pixels) Use
Default~ipad.png

Default@2x~ipad.png
768x1004

1536x2008
This is the basic loading image that is used if a more specific image is not available. If no more specific images are supplied, this should be present.
Default-Portrait~ipad.png

Default-Portrait@2x~ipad.png
768x1004

1536x2008
This is the generic portrait-loading image. This image is used for right side up (home button on bottom) portrait orientations and takes precedence over Default~ipad.png. Therefore, if you supply this image, Default~ipad.png is not used. Additionally, if Default-PortraitUpsideDown~ipad.png is not supplied, this image is used.
Default-Landscape~ipad.png

Default-Landscape@2x~ipad.png
1024x748

2048x1496
This is the generic landscape-loading image. This image takes precedence over Default~ipad.png. Therefore, if you supply this image, Default~ipad.png is not used. Additionally, if Default-LandscapeLeft~ipad.png or Default-LandscapeRight~ipad.png is not supplied, this image is used.
Default-PortraitUpsideDown~ipad.png

Default-PortraitUpsideDown@2x~ipad.png
768x1004

1536x2008
This is the portrait upside-down (home button on top) loading image.
Default-LandscapeLeft~ipad.png

Default-LandscapeLeft@2x~ipad.png
1024x748

2048x1496
This is the landscape left (home button on left) loading image.
Default-LandscapeRight~ipad.png

Default-LandscapeRight@2x~ipad.png
1024x748

2048x1496
This is the landscape-right (home button on right) loading image.

Newsstand Icons

The aspect ratio of all Newsstand icons should be between 1:2 and 2:1. In addition, all Newsstand icons must be flat and have 90° corners.
Description
iPhone 5 
high-resolution iPhone 
iPhone iPod touch
high-resolution iPad
iPad
Guidelines
App icon (required for all apps)114 x 114114 x 11457 x 57144 x 14472 x 72“App Icons”

UITabBarItem Icons

If your want to create an Icon for the UITabBarItem you must consider the next steps:
  1. Image -> Mode -> Grayscale
  2. "Discard color information" -> Discard
  3. Mark all [cmd A]
  4. Copy [cmd C]
  5. Layer -> Layer Mask -> Reveal all
  6. In "Chanels" (Window -> Chanels) show the "Layer 0 Mask" (click on the left)
  7. Paste [cmd V]
  8. Image -> Adjustment -> Invert [cmd I]
  9. Save for web [cmd alt shift S] as PNG 24
using the Icon size of 30x30 pixels for iPhone and double for retina display 60x60 pixels.

In general, when you are supplying a retina image you should name it with [name]@2x~iphone.png or [name]@2x~ipad.png. Then, in the IB you should put the name of the file without the whole suffix, so just [name] instead of [name]@2x~iphone.png. The image won't show up in the IB, but should be ok in the live app.

Saturday, April 20, 2013

How to change the MAC Address for Mac OS X Mountain Lion

Creating a random MAC Address
A MAC address is always in the format xx:xx:xx:xx:xx:xx. If you want to generate randomly a new MAC Address you can use the following command using openssl:
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'

Setting up the new MAC

In Mac OS X the network interface usually is en0 or en1.  The command for changing the MAC address is as follows:
sudo ifconfig en0 ether xx:xx:xx:xx:xx:xx
replacing “xx:xx:xx:xx:xx:xx” with the new MAC address. For example:
sudo ifconfig en0 ether 36:81:51:8e:f1:76

Hope help

Sunday, May 15, 2011

Problem with self.window.rootViewController on iPad 3.2

Today I've needed to fix a graphical mistake in one application. The problem is that this application must work on different iOS versions and I can not use the rootViewController in the app delegate in the way:

self.window.rootViewController = self.viewController;


Finally, I found the solution doing the next.

1) Change this line in the app delegate and replace it by

[self.window addSubview:self.viewController.view];


2) Open MainWindow.xib and select the UIViewController. Check "Resize View From XIB" in the attributes inspector

3) Set the view’s frame to applicationFrame programmatically. For example:

CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
appFrame = CGRectMake(0, 20, appFrame.size.width, appFrame.size.height);

self.viewController.view.frame=appFrame;


Next time I will explain how to know which iOS version is running in our device.

Hope help!

Saturday, May 7, 2011

How to convert NSData to NSString

Hi,

Today I need to extract and XML string from a NSData and it's something easy but not trivial

NSString* string = [[NSString alloc] initWithData:theData encoding:NSASCIIStringEncoding];


Hope help

Wednesday, April 13, 2011

Combobox in datagridviews binding classes and structures

Hi, my problem today is how to show the list of data from an structure into a datagridview using combobox in some columns.

First of all I was surfing on the internet and I found this for enums:

//CF: set to null before setting it to the current to
//clear out previous results
this.bindingSource1.DataSource = null;

this.bindingSource1.DataSource = MyDal.GetDataTable();

void _formatStatusColumn()
{
DataTable dt = new DataTable("Status");

//CF: actually how it's stored in the db.
dt.Columns.Add("Status", typeof(int));
dt.Columns.Add("Status_Name", typeof(string));

//CF: this way I can add or remove enum values, and
//the combo will always reflect the correct values.
foreach(int index in Enum.GetValues(typeof(Status)){
dt.Rows.Add(index, Enum.GetName(typeof(Status), index));
}

//CF: now for the UI column
DataGridViewComboBoxColumn statusColumn =
new DataGridViewComboBoxColumn();

//CF: seems to control where the column is placed.
statusColumn.DisplayIndex = 3;
statusColumn.HeaderText = "Status";

statusColumn.DataPropertyName = "Status";
statusColumn.DataSource = dt;
statusColumn.DisplayMember = "Status_Name";
statusColumn.ValueMember = "Status";

this.dataGridView1.Columns.Add(statusColumn);
}


This was very useful but I need something easier. I have to read a list and show the field in the combobox, so I've changed the code like that:

public void FormatResidenceColumn()
{
if (this.dataGridView1.Columns.Count > 0)
{
DataTable dt = new DataTable("Residence");

dt.Columns.Add("Residence", typeof(int));
dt.Columns.Add("Residence_Name", typeof(string));

this.dataGridView1.Columns.Remove("Residence");

if (Globals.ListOfResidences.Count > 0)
{
foreach (Residence obj in Globals.ListOfResidences)
{
dt.Rows.Add(obj.Id - 1, obj.Alias);
}
}
else
{
// Empty
dt.Rows.Add(0, "Empty");
}

//CF: now for the UI column
DataGridViewComboBoxColumn combColumn =
new DataGridViewComboBoxColumn();

//CF: seems to control where the column is placed.
combColumn.DisplayIndex = 4;
combColumn.HeaderText = "Residencia";

combColumn.DataPropertyName = "Residence";
combColumn.DataSource = dt;
combColumn.DisplayMember = "Residence_Name";
combColumn.ValueMember = "Residence";

this.dataGridView1.Columns.Add(combColumn);
}
}


where I use an global variable named ListOfResidence in this example.

Hope help!!

Sunday, April 3, 2011

How to launch Apple Store from my iphone code

Hi,

Today I will show you a simple function that launches the App Store from your application.

First of all you need to know your app's link for example looking for it in iTunes. And then write a code like this:


-(IBAction) gotoFlightInstrument {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/es/app/instrumental-flight-vuelo/id413551896?mt=8"]];
}


where
"http://itunes.apple.com/es/app/instrumental-flight-vuelo/id413551896?mt=8

is my iTunes app link.

Hope help!

Bye

Sunday, January 16, 2011

How to write text in an iPhone CGContextShowTextAtPoint

Hi,

Today I need to write a text in my iPhone using the CGContextShowTextAtPoint. First problem is that by default the text will appear inverted so we need to tranform it. The solution is for exmaple:

void drawText (CGContextRef myContext, char *title, int x, int y, int w, int h)
{
CGContextSelectFont (myContext, "Arial", h/10, kCGEncodingMacRoman);
CGContextSetRGBFillColor (myContext, 0, 0, 0, 0.99);
CGContextSetTextMatrix(myContext, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));
CGContextShowTextAtPoint (myContext, x, y, title, strlen(title));
}


The key is on the
CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0)
transformation.

Hope help!!

Sunday, January 2, 2011

How to convert iphone accelerometer raw data to degrees

Hello and Happy new year!!

Someone asked me yesterday how can we convert the iphone accelerometer outputs to degrees. Well, it's easy. We are going to use the function

CGFloat RadiansToDegrees(CGFloat radians) {return radians * 180/M_PI;};


and then, the only thing we need to do is

CGFloat angleXY=RadiansToDegrees(atan2(acceleration.y, acceleration.x));


For example, if we want to show this data in a UITextField called textXY

textXY.text=[NSString stringWithFormat:@"%f", angleXY];


Hope help!!