ibaction

When do we need button to send argument in Swift?

依然范特西╮ 提交于 2019-12-07 19:46:13
问题 When connecting a button in Xcode as @IBAction func, we can choose between Arguments: Sender or None. When do we choose Sender and when None? 回答1: Well, if the action method needs to know which button triggered it, or can make use of any of the button's properties, then you would need to pass the sender (the button) to the method. A contrived example for this would be if you have a calculator, which has a '+' and a '-' button. They both could share the action method performCalculation(sender:

NSButton Multiple clicks

本小妞迷上赌 提交于 2019-12-06 13:15:14
I have an IBAction of when the button is clicked to change my view. How can I handle multiple clicks for example if I click the button a second time to cause another action? Or do I need to delete the button after it has been clicked and then create a new one in its place? If so how do I handle the click event? You can check the clickCount of the mouseDown event: if ([event clickCount] > 1) { // ... do double-click action } else { // ... do single-click action } 来源: https://stackoverflow.com/questions/8997522/nsbutton-multiple-clicks

User Interface commands skipped in IBAction

半腔热情 提交于 2019-12-06 09:44:12
Here is my code: -(IBAction)saveDownloadedImage { NSLog(@"Test"); EXECUTED indicatorView.hidden = NO; NOT EXECUTED [indicatorView startAnimating]; NOT EXECUTED [statusLabel setText:@"WHY?"]; NOT EXECUTED [currentPicture setImage:[imageView image]]; EXECUTED ImageFileManager *fileManager = [[ImageFileManager alloc] init]; EXECUTED [fileManager saveImageToDisk:currentPicture]; EXECUTED indicatorView.hidden = YES; [statusLabel setText:@"Image saved successfully."]; EXECUTED saveButton.enabled = NO; EXECUTED } The proccess of saving takes about 5 seconds. So it would be normal to see the indicator

a button in UITableviewCell [closed]

不打扰是莪最后的温柔 提交于 2019-12-06 05:03:36
Closed . This question needs details or clarity . It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post . Closed 6 years ago . I have UItableViewCell created with a nib file, and have put in my cell a button. i hace created an IBAction to associate an action when the the user click the button.but i have a crash and i don't know what it is the problem, i have set all the things necessary. //in my .h -(IBAction)go; //in my .m -(IBAction)go { NSLog(@"hello"); } but i have a crash and nothing is show in the consol debug. how

What order do two IBActions fire when called from the same component?

一笑奈何 提交于 2019-12-05 18:48:19
I have a UIButton and I am trying to call 2 different actions from one UIButton event, since that button needs to do two things, but I need to do them in a certain order. No matter how I try, I can't seem to change the order in which the Actions fire. Is there a way for me to decide this, or is it random? In what order do IBActions get fired from the same component? Is there a way to call them in a certain order? Why not create a single, new method that is called by the button and runs your existing methods exactly the way you want? The answer to this is quite simple, all be it a bit strange.

How to implement two IBActions in UIButton without overlap?

强颜欢笑 提交于 2019-12-05 18:27:53
问题 I drag 2 IBActions from a UIButton , one with touchDown event and second with drag Inside. - (IBAction)clickButton:(UIButton *)sender { NSLog(@"Click Button"); } - (IBAction)dragInsideButton:(UIButton *)sender { NSLog(@"Drag Button"); } But when I drag inside, the touchDown action also gets fired. How to disable touchDown event when dragInside. Thanks! 回答1: i have solved a problem like this with using drag Events add events to your button in .xib file or programatically. programmatically is:

UiButton / IBAction - link from a RootView to mainView in Storyboard

折月煮酒 提交于 2019-12-05 06:21:52
问题 I try to call the main ViewController on my storyboard. In my app there is a additional .h , .m file with no xib or storyboard. In this .m file T craeted a button: UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(home:)forControlEvents:UIControlEventTouchDown]; [button setTitle:@"Show View" forState:UIControlStateNormal]; button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0); [self.view addSubview:button]; NSLog(@"Home-Button line 645

Animate UIButton Down - Xcode

我是研究僧i 提交于 2019-12-04 14:58:31
I wanted to know how I would go about animating a UIButton down when clicked via -(IBAction) Thanks in advance! Inside your IBAction UIButton *button = (UIButton*)sender; //animates button 25 pixels right and 25 pixels down. Customize CGRect newFrame = CGRectMake(button.frame.origin.x + 25, button.frame.origin.y + 25, button.frame.size.width, button.frame.size.height); [UIView animateWithDuration:0.3f delay:0.0f options: UIViewAnimationOptionCurveLinear animations:^{ [button setFrame:newFrame]; } completion:nil]; EDIT - To toggle between frames initialize boolean clicked to NO somewhere if (

How to create buttons which are activated when the user slides their finger over them on iPhone

谁说胖子不能爱 提交于 2019-12-04 13:56:45
I'm writing an iPhone application which has a piano like interface. The user is presented with a number of large buttons with no spaces between them. At the moment I've created IBActions in Interface Builder by right mouse dragging the buttons into the appropriate view controller interface file. This creates a method: -(IBAction) buttonTouchDown: (id) sender In the body of this function I've included the code which responds to this action. This works when I tap the button but but when I drag my finger over a number of buttons only the first one activates. When I drag my finger over the buttons

Thread 1: signal SIGABRT error when using IBActions?

蓝咒 提交于 2019-12-04 06:51:05
问题 I am trying to create a project using this tutorial. I did the best I could trying to recreate the code but am having some problems. Here is my code: class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { @IBOutlet var ImageView: UIImageView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } @IBAction func choosePhoto(sender: AnyObject) { let imagePickerController =