Questions tagged [target-action]

Target-action is a design pattern from Apple in which an object holds the information necessary to send a message to another object when an event occurs.

The Target-action design pattern is implemented in UIControl () in iOS / UIKit and NSControl () in macOS / AppKit.

Target Action Design Pattern

66 questions
0
votes
1 answer

Date Format not working in IOS

I have date picker to select date and display it on a label. I'm trying a format of yyyy-MM-dd. But when I select any date the label does not show the date which I have selected from date picker. How can I show this format yyyy-MM-dd? Here is my…
siddle
  • 137
  • 2
  • 10
0
votes
2 answers

How to identify which UITextField was changed with textFieldDidChange

I am using several UITextFields and want to do anytime anything changes in any one of them. It looks basically like: @IBOutlet weak var f1: UITextField! @IBOutlet weak var f2: UITextField! @IBOutlet weak var f3: UITextField! override func…
Greg
  • 667
  • 8
  • 19
0
votes
1 answer

Passing a parameter to function

//This is the function which contain my button action programatically func didSetCategory(info: FitnessCenterModel) { myButton.addTarget(self, action: #selector(Function(d: info)), for: .touchUpInside) } // my selector function…
Anil Kumar
  • 945
  • 7
  • 16
0
votes
1 answer

Is it possible to use a delegate to send a message when the event is not produced by a UIButton?

I'd like to know how to use a delegate to send a clock message to MyViewController from a class called MotionListener but am having trouble translating Apple's explanation of target-action into a workable command. Target-action is a design pattern…
Greg
  • 1,750
  • 2
  • 29
  • 56
0
votes
1 answer

CoreMotion [ViewController updateReferenceAttitude:] - why is the selector not recognised?

I’m new to CoreMotion. My first program shows deviceManager changing values for pitch, roll and yaw but crashes when it tries to set referenceAttitude - (void)updateReferenceAttitude { self.refAttitude =…
Greg
  • 1,750
  • 2
  • 29
  • 56
0
votes
3 answers

Why UIButton uses Target Action Design Pattern not Delegate Pattern and Vice Versa for UITextField

Can any one help in understanding why Apple decides to uses Target Action design pattern for event handling of UIButton not Delegate Pattern? Or, I can say why Apple choose delegation Design pattern for UITextField even same thing can be achieved by…
0
votes
2 answers

performSegue being called but not actually segueing to VC2? (Swift 3.0)

Can anyone spot my error? The left bar button works to dismiss, however the action button calls performSegue but the UI doesn't change the VC? Calling showLinkPreviewController inside ViewDidLoad works, so apparently it's a problem with the…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
0
votes
1 answer

How can I safely memory manage a button that I want to remove from the UI?

I'm making an app that is kinda like iBooks. There is some stuff on the screen, each item represented by a small thumbnail. I want the user to be able to delete the items much like when you tap the "Edit" button in iBooks - an X comes up, and the…
bpapa
  • 21,409
  • 25
  • 99
  • 147
0
votes
1 answer

Must I use protocols / delegation to have a ViewController perform an action of a UIButton created in another class?

I created a UIButton as a subview of a UIView Class. I would like to add that UIView as a subview to a UIViewController Class. I would like to add a target action in the UIViewController Class to the UIButton. In my example below, when you tap on…
iOSAppGuy
  • 633
  • 7
  • 23
0
votes
1 answer

Difference between Android Event-Listener and iOS Target-Action?

I am a Android developer ,Currently I was learning iOS development.And Confused about the target-action pattern. In android if i want to get a callback when a button clicked,I can do like this: btn.setOnClickListener(myOnClickListener); It's just…
Seth
  • 845
  • 8
  • 17
0
votes
1 answer

First UIButton fires another UIbutton event of same view

i have create two UIButton in swift and added action programmatically. When i try to click on the first button both button action are fired. But when i click on the second button none of the events are firing. var btnSort = UIButton(frame:…
LC 웃
  • 18,888
  • 9
  • 57
  • 72
0
votes
2 answers

UIButton target: action: Selector Argument

I have this method: - (void)retweet:(NSString *)idString { STTwitterAPI *twitter; [twitter postStatusRetweetWithID:idString successBlock:^(NSDictionary *status) { UIAlertView *retweetSuccess = [[UIAlertView…
raginggoat
  • 3,570
  • 10
  • 48
  • 108
0
votes
2 answers

Ios EXC_BAD_ACCESS error when clicking button

I have a view controller (vc1) that uses another class in order to get UI-elements. So the view of vc1 sets as subview another view returned from a class called Layout. The view returned from the class Layout contains a UIbutton. In the Layout…
user3355182
  • 151
  • 1
  • 2
  • 11
0
votes
1 answer

Action on second button click

I want to make a button invisible on the SECOND click. I've got an other action on the first click. How should I do this? Thanks in advance!
0
votes
2 answers

How can I specify a target for my action to point to?

I'm learning objective-c for iOS and have a question about creating my first target-action mechanism. I've got it to work, but currently I just set the target: portion of the addTarget:action:changeForControlEvents: method to nil, meaning it will…
rfarry
  • 42
  • 1
  • 7