Mindmajix

iPhone – Creating a User Interface Kit (UIKIT) – III

The UIKIT FRAMEWORK provides the crucial infrastructure needed to construct and manage iOS apps.

UI SWITCH:-

-(void)  viewDidload

{
UISwitch     * a Switch  =  [[UISwitch alloc]
InitWithFrame :  CGRectMake  (100,100,200,100)];
[ aSwitch  SetOn :   YES];
[ aSwitch  add Target  :  self
action   :   @  Selector  (Switch Changed)
ForControlEvents:   UIControlEventValueChanged];
[ self view  add sub view  :  a switch];
}
-(void)SwitchChanged
{
NSLog  ( @  “ Switch  Changed  called”);
Self .view .backgroundColor = [b8ControlViewController random color];
}
+ (UIColor     *)   random color
{
Static  Bool Seeded  = No;
If (   !seeded)
{
Seeded  =  YES;
Random  (  time  (NULL));
}
CGFloat  red  =   ( CGFloat)  random ()/ ( CGFloat) RAND . MAX;
CGFloat  blue  =  (CGFloat) random  ()/(CGFloat) RAND MAX;
CGFloat green  =   (CGFloat) random()/(CGFloat ) RAND MAX;
NSLog (@  “  color  red  =  %  f green  =     %  f   blue  =   %   f”, Red, green, blue);
return  [ UIColor  colorWithRed :red    green :green blue :blue alpha:1.of];
}

UI SegmentControl:-

-(void) viewDidLoad
{

Capture 15// segment Control:

NSArray      *a Array    =[NSArray    arraywithObjects: @ “first”,  @  “Second”, nil];
UISegmentedControl  *Segment=
[[ UISegmentedControl alloc]  initWithItems  : aArray];

Capture 15// Set frame:

Segments1 frame =   CGRectMake  (100,200,200,50.);

Capture 15// Set Target:

[Segment1  addTarget  :    self
Action  :   @  Selector   ( SegmentChanged)
ForControlEvents:  UIControlEventValueChanged];

Capture 15// Set  Images  to Segments:

[ segments1 set Image : [UIImage imageNamed : @ “1.jpg”]
For segmentAtIndex :0];

Capture 15// Set Title for each  Segment:

[ segment1   set Title: @ “one” for SegmentAtIndex:0];

Capture 15// set tag:

[ Segment1   setTag :1];

Capture 15// set tint  Color:

[ Segment1    setTintColor   : [UIColor    blackColor]];

Capture 15// adding  to view:

[self view  addSubView:  Segments1];
[segments1     release];
}
-(IBAction) SegmentControl changed:  (id) Sender
{
UISegmentedControl   *segment   =(UISegmentedControl   *)sender;
If(segment.  SelectedSegmentIndex  = = 0)
{
}
else if ( Segment. SelectedSegmentIndex = = 1)
{
}
}

UISlider  :-

-(void)  viewDidload
{
UISlider     *  aSlider   =   [[ UISlider alloc]
InitWithFrame :  CGRectMake  (50,200,200,50)];

Capture 15// setting  minimum value:

[ aSlider setMinimumValue:0];

Capture 15// setting maximum value:

[ aSlider setMaximumValue: 100];

Capture 15// setting initial value:

[ aSlider setValue  : 50];

Capture 15// setting  minimum value image:

[ aSlider setMinimumValueImage: [UIImage    imageNamed :@ “1.jpg]];

Capture 15//setting  maximum value image:

[ aSlider setMaximumvalueImage: [UIImage imageNamed:  @  “2.jpg”]];

Capture 15// adding target:

[ aSlider  addTarget   :  self
          Action       :  @ selector (SliderChanged:)
     ForControlEvent   :  UIControlEventValueChanged];
[ self view  add sub  view :  aSlider];
[ a slider       release];
UILabel    *lbl  =   [[ UILabel  alloc]  initWithFrame : CGRectMake             (260,200,50,40.)];
                     [lbl  setBackgroundColor  : [ UIColor  clear color]];
                     [ lbl setText : @ “50”];
                     [ self view addSubView  :  lbl];
                     [lbl release];
                     [ Super viewDidLoad];
         }
-(void) SliderChanged : (id) Sender
 {
UISlider     * bSlider   =   (  UISlider     *)   sender;
Lbl. Text  =   [  NSString StringWith Format: @ “%.0.of”, bSlider .value];
}

UIActivityIndicatorView:-

-(void) viewDidLoad
{
UIActivityIndicatorView *activity  =
[[UIActivityIndicatorView alloc] init];
[ activity setActivityviewStyle:
UIActivityIndicatorViewStyleWhite];
// activity center =  self  view center;
Activity. Frame  =   CGRectMake   self. View  . center;
Activity .frame  = CGRectMake (self view center .x, self. View. Center .y, 40,40);
[ activity setHidesWhenStopped :YES];
[ activity  startAnimating];
[ self view addSub view : activity];
[activity release];
}

UIProgress View:-

.h file:-

# import   <UIKIT/UIKIT .h>
@ interface slider view controller: UI view controller
{
Float  value;
UIProgressView        *progress;
}
@ end

. m file:-
-(void) viewDidLoad
{
Progress   = [[ UIProgressView    alloc] initWithFrame:
                          CGRectMake  (100,300,200,40)];
[ self view addSub view: Progress];
[ NSTimer ScheduledTimerWithTimeInterval :0.1
                  Target    :  self
                Selector    :  @ selector ( time Change)                         
               UserInfo     :   nil
                 Repeats    :   yes];
}
-(void) timer changed
{
Value+ = 0.1;
NSLog  ( @  “  timer changed called and value is % f”, value);
Int x= (int) value;
If (x = = 1)
Value = 0;
[ progress set progress : value];
}

UIProgressView :-

. h file:-

# import  <UIKIT/UIKIT . h>
@   interface  SliderViewController : UIViewController
{
Float value;
UIProgress view       * progress;
}
@ end

. m file:-

-(void) viewDidLoad
{
Progress  =  [[ UIProgressview  alloc] initWithFrame:
                         CGRectMake  (100,300,200,40)];
[ self view addSubview : Progress];
NSTimer scheduledTimerWithTimeInterval   : 0.1
               Target  :    self
                 
             Selector  :  @  selector( time Change)
            UserInfo   :  nil
             Repeats   :   yes];
}
-(void) timer changed
{
Value  +   =  0.1;
NSLog   (@  “ timer changed  called and value is % f”, value);
Int x = (int) value;
If (x = = 1)
Value   = 0;
[ progress SetProgress :   Value];
}

0 Responses on iPhone – Creating a User Interface Kit (UIKIT) – III"

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.