Pages

Showing posts with label iPhone. Show all posts
Showing posts with label iPhone. Show all posts

Thursday, September 23, 2010

Create Xcode project template

New article from Ohmu:
CodeProject. Creating an Xcode Project Template
shows how to make a project template in Xcode.
Tested. Works fine.
I made a template from the Simple project

Saturday, September 4, 2010

Simplest project for iPhone: no xib-file.

Probably, I do know the way to create "empty" iPhone project. Is it useful? I have no idea.
In the Windows world, in Visual Studio, the best way to create new project was to check "Empty project" checkbox in the Win32 application wizard.
In Xcode, for an iPhone project, the IDE generates for me a lot of files, makes folders. If I'm just learning, if I'm just testing all these files and folders just fulfill my hard disk.
So I found a way to create such "empty" project in Xcode:
1. Create new project in Xcode: Window-based template, any name,... everything's as usual.
2. In Xcode sidebar, select "Classes" and delete them. In the alert window choose "Also move to Trash".
3. Delete xib-file.
4. Modify *-info.plist file: delete the line about MainWindow - probably, the last one.
5. Open main.m file and add a simple application delegate. Then set the name of the delegate in the main() function.
Here is my main.m file:
#import <UIKit/UIKit.h>

// Application delegate
@interface Simple : NSObject <UIApplicationDelegate>
{
}

@end

@implementation Simple

- (void)applicationDidFinishLaunching: (UIApplication*)application
{
UIWindow* window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
[window setBackgroundColor: [UIColor yellowColor]];

[window makeKeyAndVisible];
}

@end


int main(int argc, char *argv[]) {

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"Simple");
[pool release];
return retVal;
}
6. Compile and Run:

Thursday, September 2, 2010

iOS 4.1. High Dynamic Range photos

Gigaom. iOS 4.1 Update Next Week, 4.2 in November
I'm not the first to update OS on my iPhone. But this announce looks very interesting. iOS 4.1 is supposed to fix the performance problems and will bring new feature - High Dynamic Range photos:
Using High Dynamic Range (HDR), the iPhone takes three photos: one at normal exposure, one under exposed, and one over exposed. iOS 4 then combines the three photos using “advanced algorithms” to create a single high-definition photograph. Both the normal exposure picture and the HDR picture are kept in the photos app on the iPhone, making it easy to choose one or the other. The demos look amazing; the HDR photos bring out features in the background that you couldn’t see in the normal exposure

Wednesday, August 11, 2010

iPhone Explorer


It's happened! iPhone Explorer. I just installed it on my Mac from here:
http://www.macroplant.com/iphoneexplorer/

Friday, July 30, 2010

Create UIView, UILabel and UIButton programmatically.

A year ago, when I needed to make my first iPhone application, Interface Builder looked for me very complicated. I came from the Microsoft Windows Mobile world where we created all GUI created programmatically (the standard controls are very poor, MFC worked too slow, etc.). My task has nothing to do with the GUI. I needed a test-wrapper for my code that was supposed to test a 3rd party framework. Google helped me to find few tutorials but all of then proposed to work with Interface Builder. It is really nice and simple to choose a control and put it on my application window in the Interface Builder. But how to connect this control with my code? In the beginning it was a kind of a rebus I had to solve. It was not very obvious for me to catch all these outlets, actions and bindings, Command- and Control-clicks, six different Inspectors,...
I hope this article will help to someone who likes me a year ago is looking for a way to make his first program without Interface Builder.

Let's assume that we know nothing about Xcode, Objective-C and Cocoa Touch - these are my conditions a year ago.

The following steps will help us to create a simple iPhone program with a label and a button:

1. Create Window-based iPhone application.
Launch Xcode. In menu File choose item "New Project...". In the project wizard that comes next, in the left panel select "Application" item in the "iPhone OS" section. Select "Windows-based Application" icon on the right and press "Choose". Next window asks to set a name for the project. Type "First" and press "Save" button. By default the project is created in the "My Document" folder.

2. Add UIView programatically.
In the project window, on the left panel that looks like the Finder sidebar you need to find FirstAppDelegate.m file. This sidebar represents as a tree all files of the project. The root of that tree is the project file. You can open this item and all others in the same was as you do with the folder in the Finder. If you have found the FirstAppDelegate.m file, click on it and its content will be shown in the right panel. There is a lot of code but we need only one function application didFinishLaunchingWithOptions. Make it look so:
/- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions
{
// Window bounds.
CGRect bounds = window.bounds;

// Create a view and add it to the window.
UIView* view = [[UIView alloc] initWithFrame: bounds];
[view setBackgroundColor: [UIColor yellowColor]];
[window addSubview: view];

[window makeKeyAndVisible];

[view release];

return YES;
}

3. Build and Run.
In Xcode, in project window, in the left-up corner you can a toolbar that now, probably, contains text "Device - 4.0. Debug. First". It is a popup button. You need to click on it and select Simulator. Now press on "Build and Run" button. If you see the simulator ruuning, if you see an ugly yellow window on it - you did everything perfect. Close the simulator and go back to Xcode - there is "Quit" item in the main menu of the simulator.

4. Add a label.
Here is the code that should be added to the same function after the line [window addSubview: view};:
CGRect labelFrame = CGRectMake( 10, 40, 100, 30 );
UILabel* label = [[UILabel alloc] initWithFrame: labelFrame];
[label setText: @"My Label"];
[label setTextColor: [UIColor orangeColor]];
[view addSubview: label];
You can Build and Run the program again to check the label is on the application screen.

5. Create new button.
After the label code in the same function we need to add the following:
CGRect buttonFrame = CGRectMake( 10, 80, 100, 30 );
UIButton *button = [[UIButton alloc] initWithFrame: buttonFrame];
[button setTitle: @"My Button" forState: UIControlStateNormal];
[button setTitleColor: [UIColor redColor] forState: UIControlStateNormal];
[view addSubview: button];
Build and Run the program. These orange label and white button with the red title is our art.
If something goes wrong, verify our working function:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions
{

// Override point for customization after application launch.


// Window bounds.
CGRect bounds = window.bounds;

// Create a view and add it to the window.
UIView* view = [[UIView alloc] initWithFrame: bounds];
[view setBackgroundColor: [UIColor yellowColor]];
[window addSubview: view];

// Create a label and add it to the view.
CGRect labelFrame = CGRectMake( 10, 40, 100, 30 );
UILabel* label = [[UILabel alloc] initWithFrame: labelFrame];
[label setText: @"My Label"];
[label setTextColor: [UIColor orangeColor]];
[view addSubview: label];

// Create a button and add it to the window.
CGRect buttonFrame = CGRectMake( 10, 80, 100, 30 );
UIButton *button = [[UIButton alloc] initWithFrame: buttonFrame];
[button setTitle: @"My Button" forState: UIControlStateNormal];
[button setTitleColor: [UIColor redColor] forState: UIControlStateNormal];
[view addSubview: button];

[window makeKeyAndVisible];

[button release];
[label release];
[view release];

return YES;
}

6. Add an action.
In our program the button does nothing. Let's add an action. In the header file (FirstAppDelegate.h) you need to add one line:
- (void)buttonClicked: (id)sender;
In Xcode, Alt-Cmd-Up keyboard shortcut will switch the editor to the header file from the m-file. If you have added this line, use the same keyboard shortcut to switch back to the m-file. and implement the action:
- (void) buttonClicked: (id)sender
{
NSLog( @"Button clicked." );
}
Now modify the code creating the button and add the following code:
[button addTarget: self 
action: @selector(buttonClicked:)
forControlEvents: UIControlEventTouchDown];
Now if you will build and run the program in the Xcode console you will see "Button clicked" text.

Saturday, July 3, 2010

Microsoft stops Kin

You are welcome to read yourself:
Microsoft pulls plug on Kin phone
I thought Microsoft had a plan to kill iPhone with an own smartphone - Kin. It looks not bad on photos. I hope the hardware was not bad too. From my point of view, the main problem is the OS installed on these smartphones. So this sentence:
"We are integrating our Kin team with the Windows Phone 7 team, incorporating valuable ideas and technologies from Kin into future Windows Phone releases and beyond."
if it is true, will make a lot of troubles for future Microsoft projects.

Tuesday, June 29, 2010

Mobile Safari Simulator

Mobile Safari Simulator on web:
http://ipadpeek.com/

Tuesday, May 18, 2010

iPhone 4G

Apple iPhone 4G specifications revealed – plan to ship 24 million iPhone 4G in 2010
Foxconn to ship 24 million iPhone 4G in 2010, says Digitimes Research
iPhone 4G has Cortex A8 processor, PowerVR SGX 535 graphics processor allowing 1GHz, and 512 MB of memory. Now my iPhone 3GS has 256MB and Cortex A8 which is clocked at 600MHz.

Sunday, May 2, 2010

iPhone OS 4

100+ new features and 1500 new API's in iPhone OS 4. Apple promises:
"What's New in iPhone OS4"
1. Multitasking
2. Video
3. Voice over IP
4. Mail
5 .In-App SMS
and many more. I'd expect new boom on AppStore.
It will work on iPhone 3G - it against all rumors saying that OS 4 will kill 3G - people expecting that 3GS is the minimal hardware for iPhone OS 4.

Sunday, April 25, 2010

Friday, February 19, 2010

Apple iPhone. Memory management.

Useful articles:
9 iPhone Memory Management Links and Resources:
http://www.mobileorchard.com/iphone-memory-management/

10 iPhone Memory Management Tips:
http://akosma.com/2009/01/28/10-iphone-memory-management-tips/

Managing memory in iPhone applications:
http://loufranco.com/blog/files/managing-memory-iphone.html

Debugging memory based crashes on iPhone:
http://loufranco.com/blog/files/debugging-memory-iphone.html

Wednesday, November 25, 2009

Have you ever seen an iPhone program?

If you have not, I'm one step ahead. Or behind? And more than one?

This is a file with the expected name - main. The file extension is m. :(
It just creates an application.
It is written in Objective-C. "C" is the last letter in this name. So you can imagine what does it mean.


Somehow I wrote one function that is supposed to load a view :(, create a label and a button and it even "works" - it runs on the phone but does nothing.

Tuesday, November 17, 2009

This web on iPhone

IMG_0021 IMG_0020

These are the screenshots from my iPhone. WMDeveloper looks on this phone nice.

Google helped to find out how to make the screenshots on iPhone:

  1. Hold the power off/on button
  2. Press on the main button.

The screenshot appears in the Photo Albums in Camera Rolls.

Google search works fine on the phone too. There is the voice search for “Destinator”:

IMG_0023

It found “Destinator” said with Russian accent.

Will see how the HTC Touch Pro 2 looks like, but till now this is the best phone I’ve had (or wanted to have).

Friday, June 26, 2009

Navigator для iPhone (AT&T, TeleNav)



Еще одна навигационная программа для iPhone. На этот раз от TeleNav. Но присутствие AT&T делает ее очень конкурентно способоной. Стандартный набор функций, но выглядит хорошо, что и не удивительно на таком устройстве.



Tuesday, June 9, 2009

Навигация для iPhone


Сегодня на блогах появился анонс о навигационной апликации для iPhone OS 3.0. Говорят о полном Car Kit, видео ролик замечательный YouTube.