ibaction

Single quotes around IBAction

坚强是说给别人听的谎言 提交于 2019-12-04 06:44:31
问题 I have a button to create an IBAction, and that button is Continue. However, when attaching the action I want to have a lower case continue. For some reason when I attach the action it is surrounded by single quotes. Why is this the case? @IBAction func `continue`() { // } 回答1: continue is a swift keyword (along with many other programming languages) and as such cannot be used for variable's or action names without being wrapped in backtick quotes. The compiler wraps it in backtick quotes as

How do I name and link an IBAction button created in a storyboard

三世轮回 提交于 2019-12-04 03:58:20
问题 I named the button "Reminders" Apparently it was supposed to link itself to the files but nothing showed up in mine. I have created a button in the storyboard but I don't know how to link it to a .m or .h file. I'm really new to this and still learning. Am I supposed to change the settings of the button and what code do I write in the files to make it work? Thanks a heap! 回答1: Here is how you add an IBOutlet to a header or a .m file: Open your storyboard editor on one window. Position it in

I can't figure how to fix this Expected identifier or '('

て烟熏妆下的殇ゞ 提交于 2019-12-02 23:28:20
问题 - (IBAction)SignUp:(id)sender; { Expected identifier or '(' IBOutlet UITextField *Firstnamefield; IBOutlet UITextField *Lastnamefield; IBOutlet UITextField *emailfield; IBOutlet UITextField *agefield; IBOutlet UITextField *passwordfield: IBOutlet UITextField *reenterpasswordfield; } 回答1: - (IBAction)SignUp:(id)sender { UITextField *Firstnamefield; UITextField *Lastnamefield; UITextField *emailfield; UITextField *agefield; UITextField *passwordfield; UITextField *reenterpasswordfield; } There

Programmatically generating UIButtons and associate those with IBAction

拈花ヽ惹草 提交于 2019-12-02 22:48:15
How do I do if I want to programatically generate a set of buttons and then associate those with IBActions? It's easy if I add the buttons in Interface Builder, but that I cannot do for this case. mrueg The buttons have the method - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents . The code to use this would look like this: UIButton *myButton = [[UIButton alloc] init...]; [myButton addTarget:something action:@selector(myAction) forControlEvents:UIControlEventTouchUpInside]; This assumes that your IBAction is named myAction and that something is the

Thread 1: signal SIGABRT error when using IBActions?

坚强是说给别人听的谎言 提交于 2019-12-02 09:32:52
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 = UIImagePickerController() imagePickerController.delegate = self let actionSheet = UIAlertController(title

How to make Segue Pass Data AND ONLY execute if certain criteria is met

别等时光非礼了梦想. 提交于 2019-12-02 07:49:09
问题 I have a Login page with a button. When I click on it, IF and ONLY IF the login was successful, I want to pass data to another class (using properties). I have tried using a Segue on the Button to pass the data, but the problem is that this Segue always goes to the next View, EVEN when the login is unsuccessful, in which case it should NOT. -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"gotoMainPage"] ) { MainPageController

ios sdk stop multitouch functionality

倾然丶 夕夏残阳落幕 提交于 2019-12-02 07:07:35
问题 I have multiple buttons, if user touches 2 or more buttons and releases simultaneously, I want to give the action of just one button. How can I do that. Thanks in advance for your help.. 回答1: Set exclusiveTouch property for all buttons to yes . If that is not working, you might have to disable all other buttons when the user is tapping on a particular button and enable it once that particular action is completed. 回答2: Try setting your view's multipleTouchEnabled property to NO . 来源: https:/

How to make Segue Pass Data AND ONLY execute if certain criteria is met

余生颓废 提交于 2019-12-02 06:18:12
I have a Login page with a button. When I click on it, IF and ONLY IF the login was successful, I want to pass data to another class (using properties). I have tried using a Segue on the Button to pass the data, but the problem is that this Segue always goes to the next View, EVEN when the login is unsuccessful, in which case it should NOT. -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"gotoMainPage"] ) { MainPageController *mpc = [segue destinationViewController]; mpc.username = @"TEST"; } How can I make the Segue ONLY go to

ios sdk stop multitouch functionality

房东的猫 提交于 2019-12-02 02:49:47
I have multiple buttons, if user touches 2 or more buttons and releases simultaneously, I want to give the action of just one button. How can I do that. Thanks in advance for your help.. Set exclusiveTouch property for all buttons to yes . If that is not working, you might have to disable all other buttons when the user is tapping on a particular button and enable it once that particular action is completed. Try setting your view's multipleTouchEnabled property to NO . 来源: https://stackoverflow.com/questions/13428439/ios-sdk-stop-multitouch-functionality

How to connect outlets and actions in Swift / MacOS programaticly

帅比萌擦擦* 提交于 2019-12-02 00:25:42
问题 I have a simple example. I connected the left button1 and label1 with ctrl-draging it to the contollerclass. How can I do the same for the right button2 label2 programaticly (without ctrl-draging) That´s my code: class ViewController: NSViewController { @IBOutlet weak var label1: NSTextField! //connected with ctrl-drag @IBOutlet weak var button1: NSButton! //connected with ctrl-drag @IBOutlet weak var label2: NSTextField! //not yet connected @IBOutlet weak var button2: NSButton! //not yet