Permalink
Browse files

[TIMOB-8547] iOS: switch change event gets fired when adding to a vie…

…w or window
  • Loading branch information...
1 parent b450994 commit 127608733cf64a44f43a87853d17c1e172174b45 @mstepanov committed Apr 5, 2012
Showing with 8 additions and 1 deletion.
  1. +4 −1 iphone/Classes/TiUISwitch.m
  2. +3 −0 iphone/Classes/TiUIView.h
  3. +1 −0 iphone/Classes/TiUIView.m
@@ -53,11 +53,14 @@ -(void)setValue_:(id)value
BOOL newValue = [TiUtils boolValue:value];
BOOL animated = !reproxying;
UISwitch * ourSwitch = [self switchView];
+ if ([ourSwitch isOn] == newValue) {
+ return;
+ }
[ourSwitch setOn:newValue animated:animated];
// Don't rely on switchChanged: - isOn can report erroneous values immediately after the value is changed!
// This only seems to happen in 4.2+ - could be an Apple bug.
- if (reproxying==NO && [self.proxy _hasListeners:@"change"])
+ if ((reproxying == NO) && configurationSet && [self.proxy _hasListeners:@"change"])
{
[self.proxy fireEvent:@"change" withObject:[NSDictionary dictionaryWithObject:value forKey:@"value"]];
}
@@ -29,6 +29,9 @@ void ModifyScrollViewForKeyboardHeightAndContentHeightWithResponderRect(UIScroll
@interface TiUIView : UIView<TiProxyDelegate,LayoutAutosizing>
{
+@protected
+ BOOL configurationSet;
+
@private
TiProxy *proxy;
TiAnimation *animation;
@@ -272,6 +272,7 @@ -(void)initializeState
-(void)configurationSet
{
// can be used to trigger things after all properties are set
+ configurationSet = YES;
}
-(void)setProxy:(TiProxy *)p

0 comments on commit 1276087

Please sign in to comment.