2016-06-02 9 views
0

私はサーバーからデータを取得していますが、スライダーはサーバー設定に設定されていますが、Thumbのスライダーと同じ値のラベルを表示する必要があります。ラベルは表示されません。あなたは、私は、これは私のコードUISliderはラベルを表示する定数を追加します

float registerOne = [[NSUserDefaults standardUserDefaults] floatForKey:@"POP01"];  //Data from server save whit NSUserDefaults 
    SinP.value = registerOne; 
    UIImageView *handleView1 = [SinP.subviews lastObject]; 
    UILabel *label = [[UILabel alloc] init]; 
    label = (UILabel*)[handleView1 viewWithTag:1010]; 
    label = [[UILabel alloc] initWithFrame:handleView1.bounds]; 
    label.tag = 1010; 
    label.backgroundColor = [UIColor blueColor]; 
    label.textColor = [UIColor whiteColor]; 
    label.textAlignment = NSTextAlignmentCenter; 
    label.hidden=NO; 
    handleView1.hidden=NO; 
    handleView1.alpha=1; 
    handleView1.backgroundColor= [UIColor blueColor]; 
    [handleView1 addSubview:label]; 
    [SinP addSubview:handleView1]; 
    label.text = [[NSUserDefaults standardUserDefaults] valueForKey:@"POP01"]; 
    NSLog(@"WHERE IS MY LABEL %@",label.text); 

答えて

0

単純なアニメーション

int64_t delayInSeconds = 0.2; 
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 

     float registerOne = [[NSUserDefaults standardUserDefaults]  floatForKey:@"POP01"]; 
     SinP.value = registerOne; 
     UIImageView *handleView1 = [SinP.subviews lastObject]; 
     UILabel *label = [[UILabel alloc] init]; 
     label = (UILabel*)[handleView1 viewWithTag:1001]; 
     label = [[UILabel alloc] initWithFrame:handleView1.bounds]; 
     label.tag = 1001; 
     label.backgroundColor = [UIColor clearColor]; 
     label.textColor = [UIColor whiteColor]; 
     label.textAlignment = NSTextAlignmentCenter; 
     handleView1.backgroundColor= [UIColor clearColor]; 
     [handleView1 addSubview:label]; 
     label.text = [NSString stringWithFormat:@"%0.0f",  self.SinP.value]; 

     }); 
あるスライダー

に触れることなく見えるようにする必要がスライドに触れた場合にのみ表示され

関連する問題