<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                1 首先我們還是創建一個Single View Application,然后打開MainStoryboard_iphone.storyboard,在IB中添加一個UISlider控件和一個Label,這個Label用來顯示Slider的值。 選中新加的Slider控件,打開Attribute Inspector,修改屬性值,設置最小值為0,最大值為100,當前值為0.5,并確保勾選上Continuous,如下圖: ![](https://box.kancloud.cn/2016-03-09_56dfc8287394c.png) 接著我們放上UISwitch控件,就是很像開關的那種控件,它只有兩個狀態:on和off,全都放上去效果就是這樣的: ![](https://box.kancloud.cn/2016-03-09_56dfc828872d8.png) 2.好了我們開始寫代碼嘍:ViewController.h: ~~~ #import <UIKit/UIKit.h> @interface ViewController : UIViewController{ UILabel *sliderlabel; UISwitch *leftSwitch; UISwitch *rightSwitch; } @property (nonatomic,retain) IBOutlet UILabel *sliderlabel; @property (nonatomic,retain) IBOutlet UISwitch *leftSwitch; @property (nonatomic,retain) IBOutlet UISwitch *rightSwitch; - (IBAction)sliderChanged:(id)sender; - (IBAction)switchChanged:(id)sender; @end ~~~ 接著是實現 ViewController.m: ~~~ #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize sliderlabel; @synthesize leftSwitch; @synthesize rightSwitch; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } else { return YES; } } - (IBAction)sliderChanged:(id)sender{ UISlider *slider=(UISlider*)sender; int progressAsInt=(int)(slider.value+0.5f); NSString *newText=[[NSString alloc] initWithFormat:@"%d",progressAsInt]; sliderlabel.text=newText; [newText release]; NSLog(@"%d",progressAsInt); } - (IBAction)switchChanged:(id)sender{ UISwitch *whichSwich=(UISwitch *)sender; BOOL setting=whichSwich.isOn; [leftSwitch setOn:setting animated:YES]; [rightSwitch setOn:setting animated:YES]; } - (void)dealloc{ [sliderlabel release]; [leftSwitch release]; [rightSwitch release]; [super dealloc]; } @end ~~~ 3.剩下的就是連接操作和輸出口: 將slider控件的value changed事件與sliderChanged方法連接在一起,將swich控件的value changed事件與swichChanged方法連接在一起,當然還要把lable控件和swich控件的輸出與ViewController的相應控件接口連接在一起。 最終實現的效果如下面兩張圖:????????????????????????????????????????????????????????? ![](https://box.kancloud.cn/2016-03-09_56dfc82897d6b.png) ![](https://box.kancloud.cn/2016-03-09_56dfc828a6a80.png) ????????????
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看