IBOutlet UISlider *sliderProgress; int progressAsInt = sliderProgress.value;
IBOutlet UISlider *sliderProgress; sliderProgress.value = 30;
- (IBAction)sliderChanged:(id)sender { UISlider *slider = (UISlider *)sender; int progressAsInt = slider.value; NSString *newValue = [[NSString alloc] initWithFormat:@"%d", progressAsInt]; valProgress.text= newValue; [newValue release]; }
int progressAsInt = slider.value;
- (IBAction)setTo30:(id)sender { sliderProgress.value = 30; } - (IBAction)setTo60:(id)sender { sliderProgress.value = 60; }
// // ViewController.h // sliderApp // // Created by Weerachai on 11/10/55 BE. // Copyright (c) 2555 Weerachai. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController { IBOutlet UILabel *valProgress; IBOutlet UISlider *sliderProgress; } - (IBAction)sliderChanged:(id)sender; - (IBAction)setTo30:(id)sender; - (IBAction)setTo60:(id)sender; @end
// // ViewController.m // sliderApp // // Created by Weerachai on 11/10/55 BE. // Copyright (c) 2555 Weerachai. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)sliderChanged:(id)sender { UISlider *slider = (UISlider *)sender; int progressAsInt = slider.value; NSString *newValue = [[NSString alloc] initWithFormat:@"%d", progressAsInt]; valProgress.text= newValue; [newValue release]; } - (IBAction)setTo30:(id)sender { sliderProgress.value = 30; } - (IBAction)setTo60:(id)sender { sliderProgress.value = 60; } - (void)dealloc { [valProgress release]; [sliderProgress release]; [super dealloc]; } @end
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท