0

I have Slider in my app that is connected to a few methods. In my viewDidLoad, I am setting a custom thumb and image, neither of which appear. There are no errors or warnings, just that the slider doesn't seem to be connected to my code, even though I made the connections in the .xib I am getting the NSLog printout, so I know that the viewDidLoad method is being called.

- (void)viewDidLoad {
    [super viewDidLoad];

    // initialize custom UISlider (you have to do this in viewdidload or applicationdidfinishlaunching.
    UIImage *stetchLeftTrack= [[UIImage imageNamed:@"Nothing"]
                               stretchableImageWithLeftCapWidth:30.0 topCapHeight:0.0];
    UIImage *stetchRightTrack= [[UIImage imageNamed:@"Nothing"]
                                stretchableImageWithLeftCapWidth:30.0 topCapHeight:0.0];
    [slideToUnlock setThumbImage: [UIImage imageNamed:@"SlideToStop"] forState:UIControlStateNormal];
    [slideToUnlock setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
    [slideToUnlock setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];
    NSLog(@"WATERMELON");
}
Alex
  • 103
  • 2
  • 8
  • What does NSLog(@"slideToUnlock: %@", slideToUnlock) yield if you put it where you have NSLog(@"Watermelon")? I ask, because the first thing here is to eliminate the possibility that it is nil. If it's not nil, also check the images you are loading are not nil. – Obliquely Mar 25 '12 at 18:32
  • Turns out it is null. How might I prevent this? – Alex Mar 25 '12 at 18:55

2 Answers2

0

Using Touch Punch :-

<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.21/jquery-ui.min.js"></script>
<script src="jquery.ui.touch-punch.min.js"></script>


<script>$('#widget').draggable();</script>

try to avoid multiple js . it may create problem on safari you can get touch punch from http://touchpunch.furf.com/

Bharat Parmar
  • 1,842
  • 2
  • 18
  • 22
0

If slideToUnlock is null then you need to:

  • check your @property and @synthesize statements
  • check everything is wired up right to your xib

I'd also recommend using the accessor for slideToUnlock, i.e. [self slideToUnlock] rather than accessing the variable directly.

If you're not using ARC, then @property and @synthesize will look like this:

@property (nonatomic, retain) IBOutlet UISlider* slideToUnlock;
@synthesize slideToUnlock = _slideToUnlock; // make the ivar _slideToUnlock to distinguish it from the property

If you're using ARC (I don't myself) then this question gives guidance:

Community
  • 1
  • 1
Obliquely
  • 7,002
  • 2
  • 32
  • 51
  • Ahh. The problem was that I was referring to slideToUnlock instead of _slideToUnlock, as I had set @synthesize slideToUnlock = _slideToUnlock; – Alex Mar 25 '12 at 23:43