![]() Big companies, especially banks, usually have processes in place to ensure that their software is secure, robust, and maintainable. MsgLabel.A few years ago, when I was still an employee in a mobile consultancy, I worked on an app for a big investment bank. All rights reserved.Ĭlass ViewController: UIViewController weak var msgLabel: UILabel! ![]() SwiftOneFunctionPorecessMultipleButtonClickExample ![]() Now you only need to add below swift source code in ViewController.swift source file, in the source code, we use the event source button’s tag attribute value to identify which button sends the event, then change the label text accordingly.You can see the demo video for this step at the end of this article. So to connect multiple buttons to the same IBAction function, you just need to press the Control key and drag every button from the Main.storyboard to the same IBAction function in the assistant editor. To make Button Two use the same IBAction function to process it’s Touch Up Inside event, you should press the Control key and drag Button Two from the Main.storyboard to the assistant editor and connect it to the same IBAction function which Button One is used like in below video.You can refer article How To Connect Storyboard UI Component To ViewController Class Code. Press the Control key and drag B utton One from the Main.storyboard file to the assistant editor to create one IBAction function to process it’s Touch Up Inside event. Now open the assistant editor by click View -> Assistant Editor -> Show Assistant Editor menu item at Xcode top menu bar.Now each button has one Tag attribute value, and the value is unique.Select Button Two and set its Tag attribute value with 2.The tag value for each UI component should be unique in the same Xcode project, we use this tag value to identify the UI component uniquely. ![]() Scroll down the attributes inspector panel, until you see Tag attribute in the View section like above, then input value 1 in the text box after Tag attribute.Click Main.storyboard file to open it, then select Button One on the screen, and click View -> Inspectors -> Show Attributes Inspector menu item to display the button’s attribute inspector panel in Xcode project right side like below. Now we need to set tag attribute value for the two buttons.To make the label text align center, you should select the label in the Main.storyboard file, then click View -> Inspectors -> Show Attributes Inspector menu item at the Xcode top menu bar to open the attributes inspector, then click Center alignment in Alignment section.Then click Fill Container Horizontally drop down item to select it in the Size inspector -> View -> Arrange ( Position View ) ->Fill Container drop-down list. To make the three UI components full fill the screen width, just select it, then click View -> Inspectors -> Show Size Inspector menu item at the Xcode top menu bar to display the Size Inspector.You can refer article How To Display Xcode Library, Assistant Editor, Inspectors Window. Open Xcode UI component Library and add one label and two buttons in the screen by edit the Main.storyboard file.Create a new swift Xcode project, you can refer article How To Create A Swift Project In Xcode.The two buttons’ click events are processed in one IBAction function. There are one label and two buttons on the screen, when you click the different buttons, it will display different text in the label. First, let us look at the example demo video as above.If the above video can not be seen, you can watch it on URL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |