i have 2 tableviews in my application with 5 UISwitch in each view.For every switch there is an action.Now i decide to change the label text of switch.I was able to change the label text from ON_OFF to YES_NO . But after implementing this method in a seperate class which is a UISwitch class i am not able to call the action method for that particular switch.The same is working well if i doesn't implement this method to change the label text. Can anybody suggest me that were i am going wrong.
A:
You should post some actual code; particularly how you changed the label text. Are you using undocumented APIs? The UISwitch class reference specifically says it's not customizable.
When you say things like "implementing this method in a seperate class which is a UISwitch class," do you mean you've subclassed UISwitch? This also isn't supported. It's a clunky control and there's not a lot that can be done about it without building your own.
Rob Napier
2009-06-15 14:59:31
http://github.com/ars/uiswitch-extension--for-iphone-/tree/master This is the link from where i have changed the text.
iamsult
2009-06-16 09:23:38
Since you're diving into the private views of UISwitch, you'll have to start guessing how Apple may have implemented it under the covers. You're messing with the view tags; are you sure Apple wasn't using them? I'd try to make as few assumptions as possible about the underlying implementation, so I wouldn't use view tags. Just find the views you want and change their text. Don't try to create quick access to the views. It's very possible that Apple relies on the text itself to know which was touched, so you may have to leave the .text attribute alone and modify how the label is drawn instead.
Rob Napier
2009-06-16 14:30:43
Oh, and be prepared for this to break in future versions of iPhoneOS. I fully expect major changes in UISwitch's implementation. Often when Apple makes something overly private it's because it's really ugly and they want to be able to fix it without breaking existing code (that being "existing code that follows the API").
Rob Napier
2009-06-16 14:32:19