Przeglądaj źródła

getting and setting values works now for fonts and text values, still need to work on colors and switches

Kevin Bradley 5 lat temu
rodzic
commit
683a0bb654

+ 5 - 2
Classes/Editing/FLEXFieldEditorViewController.h

@@ -18,10 +18,13 @@ NS_ASSUME_NONNULL_BEGIN
 + (nullable instancetype)target:(id)target property:(FLEXProperty *)property commitHandler:(void(^_Nullable)())onCommit;
 /// @return nil if the ivar type is unsupported
 + (nullable instancetype)target:(id)target ivar:(FLEXIvar *)ivar commitHandler:(void(^_Nullable)())onCommit;
-
+#if TARGET_OS_TV
+/// Subclasses can change the button title via the \c title property
+@property (nonatomic, readonly) UIButton *getterButton;
+#else
 /// Subclasses can change the button title via the \c title property
 @property (nonatomic, readonly) UIBarButtonItem *getterButton;
-
+#endif
 - (void)getterButtonPressed:(id)sender;
 
 @end

+ 10 - 3
Classes/Editing/FLEXFieldEditorViewController.m

@@ -56,7 +56,7 @@
     [super viewDidLoad];
 
     self.view.backgroundColor = FLEXColor.groupedBackgroundColor;
-
+    #if !TARGET_OS_TV
     // Create getter button
     _getterButton = [[UIBarButtonItem alloc]
         initWithTitle:@"Get"
@@ -64,10 +64,17 @@
         target:self
         action:@selector(getterButtonPressed:)
     ];
-    #if !TARGET_OS_TV
+
     self.toolbarItems = @[
         UIBarButtonItem.flex_flexibleSpace, self.getterButton, self.actionButton
     ];
+    
+    #else
+    _getterButton = [UIButton buttonWithType:UIButtonTypeSystem];
+    [_getterButton setTitle:@"Get" forState:UIControlStateNormal];
+    [_getterButton addTarget:self action:@selector(getterButtonPressed:) forControlEvents:UIControlEventPrimaryActionTriggered];
+    _getterButton.frame = CGRectMake(100, 600, 200, 60);
+    [self.view addSubview:_getterButton];
     #endif
 
     // Configure input view
@@ -80,9 +87,9 @@
     // Don't show a "set" button for switches; we mutate when the switch is flipped
     if ([inputView isKindOfClass:[FLEXArgumentInputSwitchView class]]) {
         self.actionButton.enabled = NO;
+#if !TARGET_OS_TV
         self.actionButton.title = @"Flip the switch to call the setter";
         // Put getter button before setter button
-        #if !TARGET_OS_TV
         self.toolbarItems = @[
             UIBarButtonItem.flex_flexibleSpace, self.actionButton, self.getterButton
         ];

+ 4 - 2
Classes/Editing/FLEXMethodCallingViewController.m

@@ -39,9 +39,11 @@
 
 - (void)viewDidLoad {
     [super viewDidLoad];
-
+#if !TARGET_OS_TV
     self.actionButton.title = @"Call";
-
+#else
+    [self.actionButton setTitle:@"Call" forState:UIControlStateNormal];
+#endif
     // Configure field editor view
     self.fieldEditorView.argumentInputViews = [self argumentInputViews];
     self.fieldEditorView.fieldDescription = [NSString stringWithFormat:

+ 5 - 0
Classes/Editing/FLEXVariableEditorViewController.h

@@ -39,8 +39,13 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, readonly, nullable) FLEXArgumentInputView *firstInputView;
 
 @property (nonatomic, readonly) FLEXFieldEditorView *fieldEditorView;
+#if TARGET_OS_TV
+/// Subclasses can change the button title via the button's \c title property
+@property (nonatomic, readonly) UIButton *actionButton;
+#else
 /// Subclasses can change the button title via the button's \c title property
 @property (nonatomic, readonly) UIBarButtonItem *actionButton;
+#endif
 
 /// Subclasses should override to provide "set" functionality.
 /// The commit handler--if present--is called here.

+ 9 - 3
Classes/Editing/FLEXVariableEditorViewController.m

@@ -96,17 +96,23 @@
     _fieldEditorView = [FLEXFieldEditorView new];
     self.fieldEditorView.targetDescription = [NSString stringWithFormat:@"%@ %p", [self.target class], self.target];
     [self.scrollView addSubview:self.fieldEditorView];
-    
+#if !TARGET_OS_TV
     _actionButton = [[UIBarButtonItem alloc]
         initWithTitle:@"Set"
         style:UIBarButtonItemStyleDone
         target:self
         action:@selector(actionButtonPressed:)
     ];
-    #if !TARGET_OS_TV
+    
     self.navigationController.toolbarHidden = NO;
     self.toolbarItems = @[UIBarButtonItem.flex_flexibleSpace, self.actionButton];
-    #endif
+#else
+    _actionButton = [UIButton buttonWithType:UIButtonTypeSystem];
+    [_actionButton setTitle:@"Set" forState:UIControlStateNormal];
+    [_actionButton addTarget:self action:@selector(actionButtonPressed:) forControlEvents:UIControlEventPrimaryActionTriggered];
+    _actionButton.frame = CGRectMake(500, 600, 200, 60);
+    [self.view addSubview:_actionButton];
+#endif
 }
 
 - (void)viewWillLayoutSubviews {