0

following code was worked for me in xcode 3 but not in code 4 should i have to change something ?

[switchViewSession setCenter:CGPointMake(160.0f,260.0f)];
((UILabel *)[[[[[[switchViewSession subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:0]).font=[UIFont fontWithName:@"Georgia" size:12.0f];
((UILabel *)[[[[[[switchViewSession subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:0]).text = @"Pause";

((UILabel *)[[[[[[switchViewSession subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:1]).font=[UIFont fontWithName:@"Georgia" size:10.0f];
((UILabel *)[[[[[[switchViewSession subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:1]).text = @"Continue";
[switchViewSession setOn:YES];
cell.accessoryView = switchViewSession;
Abizern
  • 146,289
  • 39
  • 203
  • 257
Pooja
  • 2,162
  • 5
  • 33
  • 64
  • When you say it doesn't work, what do you mean? Have you tried stepping through and making sure that since you are enumerating through so many subviews you are getting the object you want? As an aside, this could really do with some refactoring. – Abizern Jul 25 '11 at 09:39
  • I'll add another comment, to say see [what Kevin Ballard said](http://stackoverflow.com/questions/4806743/changing-of-uiswitch-text-in-ios-4-2/4809479#4809479) to answer a question with similar code. It seems that they've changed the internal layout between versions and your assumptions about the view hierarchy no longer hold. – Abizern Jul 25 '11 at 09:43
  • @Abizern i read already but still dont know how to change text of uiswitch – Pooja Jul 25 '11 at 09:47

2 Answers2

1

Check it out http://cocoacontrols.com/platforms/ios/controls/ssswitch

0

Have a look at how it is done in the open source replacement and see if that helps.

Abizern
  • 146,289
  • 39
  • 203
  • 257