Wednesday, April 21, 2010

Creating UIButton manually on IPhone SDK

Recently I started to learn iPhone development just for fun. iPhone sdk comes with great IDE which has great tool like memory leak finder, profiler, interface builder and other such tool. To create UI for iPhone application interface builder is great tool, but sometime we need to create control programatically at runtime. I also faced same situation to create UIButton control at runtime.

So here I am sharing my learning to create UIButton at runtime and adding it to view.

In following, I am creating UIButton named customButton, setting its location and size on screen and then image for normal and highlighted state.

UIButton* customButton = [UIButton buttonWithType:UIButtonTypeCustom];
[customButton setFrame:CGRectMake(10,10, 100, 100)];
[customButton setImage:[UIImage imageNamed:@"blue-ind.png"] forState:UIControlStateNormal];
[customButton setImage:[UIImage imageNamed:@"red-ind.png"] forState:UIControlStateHighlighted];
Then I am specify what function needed to be called when button get pressed using addTarget method of UIButton.

[customButton addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
Finally adding button to view.

[self.view addSubview:customButton];
Now when above button is clicked, btnClicked method will be get called. I have used following declaration and definition for btnClicked method.

-(void) btnClicked ;

-(void) btnClicked {
    NSLog(@"Custom button clicked");
}
Here is output of above code.



Friday, April 16, 2010

Live Wallpapers for N900

I found this cool application that makes your wallpaper live and animated.

Here is video fro that application.



Find more information on original blog here.

Monday, April 12, 2010

Video cutter in Ubuntu

Recently I needed to create video demo for one for my developed application, and I needed to remove some unwanted portion from video. In windows there are plenty of application for doing so, but now I use Ubuntu operating system. I search for video editing software for Ubuntu and I found one great application.

Its command line tool and its name is ffmpeg.

It can cut video clip from large video, if you want to crop video it support this as well and it support wide range of video codec.

To install this tool type following command on terminal


sudo apt-get install ffmpeg

Following command will clip video and put it in output file

ffmpeg -i movie.avi -ss 00:51:42 -t 00:03:30 clip.avi

To crop video , use following commands

ffmpeg -i input.avi -croptop 50 output.avi
ffmpeg -i input.avi -cropbottom 50 output.avi

To change aspect ration use following command

ffmpeg -i input.avi -aspect 16:9 output.avi

Here is documentation for ffmpeg tool it you need some more options.

Thursday, April 8, 2010

Interesting concept from Intel

Check out this project from Intel Research & the University of Washington that users pico projectors and cameras to extend the user interface to our surroundings.

Wednesday, April 7, 2010

Speed match in Reaction game

Recently I was not able to post anything new. I was busy in updating Reaction game with new game option called Speed Match.

In Speed match you have to remember shape and you have to answer if currnely displayed shape is matching previous shape or not. This game help you to improve your reaction time, working memory and also information processing speed.

Here are few snaps from game.






Scoring is still not in proper shape, i have not considered time taken to answer. I am currenly working on that will update it soon.

If you are instrested in code than i have uploded code on gitorious. To try game on N900, add extra devel repository to application manager and then type "apt-get install reaction" on xterm.