Flipkart Search

Search This Blog

Saturday, May 2, 2009

Custom UITableViewCell in IB

Creating the project

Create a new project with the “View-based Application” template and call it customTableCell.

Setting up the view controller

Open customTableCellViewController.h and add two IB outlets which we will use to reference to the custom UITableViewCell objects which we will create later. Also, we are going to be using this as a table view delegate and data source so we should state that this class will conform to these protocols. Your customTableCellViewController.h should look like this after editing:

#import 

@interface customTableCellViewController : UIViewController {
IBOutlet UITableViewCell *cellOne;
IBOutlet UITableViewCell *cellTwo;
}

@property (nonatomic, retain) IBOutlet UITableViewCell *cellOne;
@property (nonatomic, retain) IBOutlet UITableViewCell *cellTwo;

@end

Adding the items in Interface Builder

Open customTableCellViewController.xib in IB and drop in a Table View (not a Table View Controller), making it fill the view.

Set the the table view properties to Style -> Grouped.

Link the delegate and dataSource outlets of the table view to “File’s Owner” as illustrated by this screenshot:

ib-tableview-links.png

Add two Table View Cell items in IB to your customTableCellViewController.xib file. Then, open each table view cell item and drop something different onto each one of them so you will tell them apart.

Now we need to link these table view cells to the IB outlets we created earlier. To do this, right click on “File’s Owner” and link cellOne and cellTwo outlets to the table view cells you have just created. You should then have something which looks like this:

ib-cell-links.png

Save and close customTableCellViewController.xib.

Controller Code

Open customTableViewController.m

We will need to implement three functions, namely tableView:cellForRowAtIndexPath:, numberOfSectionsInTableView: and tableView:numberOfRowsInSection: which are the usual data source protocol functions which we need to implement. The three functions are outlined below.

tableView:cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if([indexPath row] == 0) return cellOne;
if([indexPath row] == 1) return cellTwo;
return nil;
}

numberOfSectionsInTableView:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

tableView:numberOfRowsInSection:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 2;
}

These functions tell the table view to display 1 section, with 2 cells and when the table view asks for each cell, the custom UITableViewCell objects are returned.

And that’s it!

If you now build and run the application then you will notice that your custom cells are being shown - brilliant! Now you can do something fun with the custom cells! For instance you could put a text box or a slider in it and then bind actions of it to a function in your view controller to act upon the user’s input.

Go play!

http://ericasadun.com/

http://steaps.techaos.com/2009/03/01/tutorial-scrolling-an-object-into-view/

http://www.ipodtouchfans.com/forums/archive/index.php/t-102782.html
http://twilloapp.blogspot.com/
http://blog.mcilvena.com/2009/01/xcode-starting-point-for-iphone-hand-coders/
http://vimeo.com/3363949
http://iphonedevelopertips.com/xcode/real-men-dont-use-interface-builder.html

http://www.ipodtouchfans.com/forums/archive/index.php/f-55.html
http://forums.macrumors.com/archive/index.php/f-135-p-6.html
http://blogs.remobjects.com/blogs/mh/2009/04/11/p271
http://www.ipodtouchfans.com/forums/archive/index.php?t-58898.html
http://www.servin.com/iphone/NSObject.html
http://weblog.bignerdranch.com/?p=56
http://www.insanelymac.com/forum/index.php?showtopic=96104&st=40

http://ihatetheiphonesdk.blogspot.com/2008/04/reason-2-interface-builder-is-buggy-and.html

http://kwigbo.com/wp/2009/02/27/custom-uitableviewcell-in-interface-builder/

http://iphone.galloway.me.uk/iphone-sdktutorials/custom-uitableviewcell/

http://iphone.zcentric.com/2008/08/05/custom-uitableviewcell/

Friday, May 1, 2009

// This will get a random number between 0 and 9
int ranX = arc4random() % 10;

Cocos2d Rectangle Rectangle Collision Detection

- (BOOL) rect:(CGRect) rect collisionWithRect:(CGRect) rectTwo
{
float rect_x1 = rect.origin.x;
float rect_x2 = rect_x1+rect.size.width;

float rect_y1 = rect.origin.y;
float rect_y2 = rect_y1+rect.size.height;

float rect2_x1 = rectTwo.origin.x;
float rect2_x2 = rect2_x1+rectTwo.size.width;

float rect2_y1 = rectTwo.origin.y;
float rect2_y2 = rect2_y1+rectTwo.size.height;

if((rect_x2 > rect2_x1 && rect_x1 < rect2_x2) &&(rect_y2 > rect2_y1 && rect_y1 < rect2_y2))
return YES;

return NO;
}

iPhone SDK Show Activity Indicator in the Status Bar

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;


iPhone SDK dismiss the keyboard

Q: How do you remove the keyboard when the Return/Done button is pressed?
A: Set the delegate on the text field that will bring up the keyboard. Add the following selector to the object that you set to be the delegate.

- (BOOL) textFieldShouldReturn:(UITextField *) textField
{
[textField resignFirstResponder];

return YES;
}

iPhone SDK Load Text File Into NSString

NSString *path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"txt"]; 
NSString *fileText = [NSString stringWithContentsOfFile:path];


Create UIButton/button with images

UIButton *playButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];

playButton.frame = CGRectMake(110.0, 360.0, 100.0, 30.0);

[playButton setTitle:@"Play" forState:UIControlStateNormal];

playButton.backgroundColor = [UIColor clearColor];

[playButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ];

UIImage *buttonImageNormal = [UIImage imageNamed:@"blueButton.png"];

UIImage *strechableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];

[playButton setBackgroundImage:strechableButtonImageNormal forState:UIControlStateNormal];

UIImage *buttonImagePressed = [UIImage imageNamed:@"whiteButton.png"];

UIImage *strechableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];

[playButton setBackgroundImage:strechableButtonImagePressed forState:UIControlStateHighlighted];

[playButton addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:playButton];

Splash Screen

Show splash screen during loading

//In AppDelegate.m

- (void)applicationDidFinishLaunching:(UIApplication *)application {

m_viewController = [[SplashViewController alloc] initWithNibName:nil bundle:nil];

[window addSubview:m_viewController.view];

[window makeKeyAndVisible];

//set delay before showing new screen

[NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(onSlashScreenExpired:) userInfo:nil repeats:NO];

}

- (void)onSlashScreenExpired:(id)userInfo{

[m_viewController.view removeFromSuperview];

[window addSubview:[navigationController view]];

[window makeKeyAndVisible];

}

Wednesday, April 29, 2009

http://www.servin.com/iphone/iPhone-Programming-Window-Based-App.pdf
http://www.raddonline.com/blogs/geek-journal/iphone-sdk-uinavigationcontroller-hiding-the-navigation-bar/
http://www.iphonedevsdk.com/forum/iphone-sdk-development/13832-please-correct-me-design-code.html
http://cocoadevcentral.com/articles/000064.php
http://www.iphonedevsdk.com/forum/iphone-sdk-development/11585-editable-uitableview-custom-uitableviewcell.html

http://www.google.co.in/search?hl=en&q=how+to+make+window+based+application+template+behave+like+navigation+based+application+template&btnG=Search&meta=&aq=o&oq=




http://mashable.com/2009/02/21/how-to-build-an-iphone-app/
http://blog.daveverwer.com/iphone-development/build-an-iphone-app-in-20-minutes-source-code/
http://eequalsmcsquare.com/iPhone-SDK?page=8
http://www.iphonemusings.com/2009/01/iphone-programming-tutorial-creating.html
http://www.switchonthecode.com/tutorials/an-absolute-beginners-guide-to-iphone-development#comment-2724
http://www.switchonthecode.com/tutorials/an-absolute-beginners-guide-to-iphone-development#comment-2724
http://www.skylarcantu.com/blog/iphone-tutorials/
http://iphonesdksnippets.com

http://www.e-string.com/content/custom-uitableviewcells-interface-builder
http://iphonelessons.wordpress.com/2009/02/21/hello-world/
http://www.switchonthecode.com/neat-websites/great-set-of-video-tutorials-on-iphone-uitableview

http://revver.com/video/887191/uitableview-iphone-programming-tutorial/
http://cocoacast.com/?q=node/182
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html

http://www.littlecomputers.net/?page_id=549
http://miketeo.net/wp/index.php/2008/08/31/simple-iphone-tutorial-part-1.html

Tuesday, April 28, 2009

http://www.servin.com/iphone/iPhone-Table-of-Colors-Mini-Course.html

http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewAndDataModel/TableViewAndDataModel.html

http://www.switchonthecode.com/tutorials/an-absolute-beginners-guide-to-iphone-development

Monday, April 27, 2009

http://www.roseindia.net/ittraining/iPhone-Development-Training.shtml

http://blog.jayway.com/2009/03/22/uitoolbars-in-iphone-os-2x/

UITableView iPhone Programming Tutorial - Part 1

http://www.youtube.com/watch?v=e0zi5pQgpaY



iPhone App Tutorial 1


http://www.youtube.com/watch?v=Tz9mzB2fWhs


http://speckyboy.com/2008/07/18/35-free-icon-sets-for-your-iphone-pimp-it-up/

Friday, April 24, 2009

http://icezero.softarchive.net/beginning_iphone_development_exploring_the_iphone_sdk.28459.html

http://www.cimgf.com/2008/10/01/cocoa-touch-tutorial-iphone-application-example/

Thursday, April 2, 2009

Flow chart assignment

1. Take the input n from user and print the n steps of Fibonacci series.
2. Check whether the number is Armstrong or not ?
3. Take the input from user and reverse the number
4. Take four numbers from user and Get Min, Max and Average among these numbers.
5. Take n number of array (input) from user and sort the array.
6. Find the factorial of given number.
7. Take two array of number and put the common element in third array.