#import
@interface StartUpViewController : UIViewController {
UIPickerView *accuracyPicker;
NSArray *pickerItems;
}
@property(nonatomic,retain)UIPickerView *accuracyPicker;
@end
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
pickerItems = [[NSArray alloc] initWithObjects:@"Best",@"10 \t KMS",@"20 \t KMS",@"30 \t KMS",@"40 \t KMS",nil];
}
return self;
}
// returns the number of columns to display.
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
// returns the number of rows
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [pickerItems count];
}
#pragma mark ---- UIPickerViewDelegate delegate methods ----
// returns the title of each row
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSString *currentItem = [pickerItems objectAtIndex:row];
return currentItem ;
}
// gets called when the user settles on a row
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSString *currentItem = [pickerItems objectAtIndex:row];
printf("\n Accuracy set :%s",[currentItem UTF8String]);
}
- (void)viewDidLoad {
[super viewDidLoad];
UIView *mview = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
//[[UIScreen mainScreen] applicationFrame] this fits the view frame to complete secreen
accuracyPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 75, 100, 100)];
//creating the picker view
accuracyPicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
accuracyPicker.delegate = self;
accuracyPicker.dataSource = self;
accuracyPicker.showsSelectionIndicator=YES;//for showing the picker
mview.backgroundColor=[UIColor darkGrayColor];//for the background color
[mview addSubview:accuracyPicker];
self.title =@"Welcome to Hotels App";
self.view = mview;
[mview release];
}
- pradeep T
- chennai, India
-
►
2012
(7)
- ► 03/04 - 03/11 (3)
- ► 01/08 - 01/15 (4)
-
▼
2009
(12)
- ► 02/15 - 02/22 (2)
-
►
2008
(2)
- ► 09/07 - 09/14 (1)
- ► 08/24 - 08/31 (1)
About Me
Blog Archive
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment