Mindmajix

iPhone – UI Picker view

Picker view:-

A picker view lets the user choose between certain options by spinning a wheel on the screen. Picker views are well suited for choosing things like dates and times (as the date picker does) that have a moderate number of discrete options. Pickers consist of a rotating scrollable view, which is used for picking a value from the list of items.

.h file:-

 # import   <UIKIT/UIKIT .h>
 @ interface   divpickerviewController  :   UIviewController
 {
 NsMutableArray      * aArray;
 }
@ end

.m file:-

# import  “ divpickerview  viewController .h”
@ implementation   divPickerview   viewController
-(void)    viewDidLoad
{
a Array  =   [[ NSMutableArray   alloc]  initWithObjects:
@ “one”, @ “two”, @ “three”, @ “four”, @ “five”, nil];
[ super   viewDidLoad];
}

# Program Mark Pickerview Data Source:

Capture 15

-( NSInteger)  numberOfComponentsInpicker view:
( UIPicker view    :)  pickerview
{
Return   4;
}

Capture 15

-(NSInteger)  pickerview:  (  UIpicker view     *)   pickerview
NumberofRowsInComponent:  ( NSInteger)Component
{
Return  [     aArray   Count];
}

Capture 15

-(NSString       *)  pickerview   :   (UIPickerview     *)    pickerview
titleForRow: ( NSInteger)   row  forComponent:
(NSInteger )Component;
{
return  [aArray  objectAtIndex   :  row];
}

Capture 15

-(void)   picker view :  (UIpicker view     *)   pickerview
didSelectRow:  ( NSInteger)  row  in ComponenT :
(NSInteger)Component
{
NSLog   (   @ “ didSelectRow is called  and  row  is %d  and  component  is %d”,   row  Component);
}

Output:-

one one one one
two two two two
Three Three Three Three
Four Four Four Four
Five Five Five Five

Data Picker View:   

. h file:

# import   <UIKIT/UIKIT .h>
@ interface    divdatepickerviewController: UIViewController
{
IBoutlet       UIDatePicker    * Datepicker;
}
-(   IBAction)   dateChanged;
@ end

.m file:-

# import “ divdatepickerviewController. h”
@  implementation   divdatepickerviewController
-(IB action) dateChanged
{
NSDate       *  date   =    [   datepicker   date];
NSLog   (   @   “date  is %@”, date);
}
Fri Jul.15

Sat Jul.16

2

3

55

00

AM
Today 4 05 PM
Mon Jul18 5 10
Tue Jul19 6 15

Image picker view:-

.h file:-

# import    <UIKIT/UIKIT .h>
@ interface   b8  ImagePickerviewController :  UIviewController

< UINavigationControllerDelegate, UIImagePicker Controller  Delegate>
{
}
-(IBAction)  buttonClicked;
@ end

.m  file:-

# import  “b8ImagePickerviewController. h”
@ implementation b8ImagepickerviewController
-(IBAction)  buttonClicked
{
UIImagePickerController     * picker  =    [[ UIImagepickerController alloc]  init];
[Picker  SetSourceType: UIImagePickerControllerSourceTypephoto Library];
[picker  setDelegate  :  self];
Picker . editing  =   YES;
[self PresentModelViewController: picker  animated  : YES];
}
-(void) imagePickerController  : (UIImagePickerController    *)
Picker  didFinishPickingMedia withInfo:
(NSDictionary    *) info
{
NSLog  ( @ “editing info   is %@”,  info);
UIImage    * image  = [info  objectForkey: @ “UIImagePicker ControllerOriginalImage”];
Self. view  .backgroundColor  = [UI color  Colorwithpattern Image : image];
[ picker dismissModelviewControllerAnimated  : YES”];
}
-(void) imagepickerControllerDidCancel : ( UIImagePickerController    *) picker
{
[ self dismiss model viewControllerAnimated  : YES];
}

 

 


 

0 Responses on iPhone – UI Picker view"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.