IOS_1 _ Divider

Source: Internet
Author: User

IOS_1 _ Divider

BeyondViewController. h

//// BeyondViewController. h // 01_calc /// Created by beyond on 14-7-20. // Copyright (c) 2014 com. beyond. all rights reserved. // # import
 
  
@ Interface BeyondViewController: UIViewController // the unique purpose of IBOutlet IBAction is to make these member attributes and methods in the Controller header file, it can appear in the right-click list of storyboard. // The controller defines a member and waits for controls on the interface to connect to @ property (nonatomic, weak) IBOutlet UITextField * num1; @ property (nonatomic, weak) IBOutlet UITextField * num2; @ property (nonatomic, weak) IBOutlet UILabel * result; // The controller defines an object method, wait for the button to be clicked on the interface (here is the declaration)-(IBAction) btnClick :( UIButton *) sender; @ end
 

BeyondViewController. m

//// BeyondViewController. m // 01_calc /// Created by beyond on 14-7-20. // Copyright (c) 2014 com. beyond. all rights reserved. // # import "BeyondViewController. h "@ interface BeyondViewController () @ end @ implementation BeyondViewController-(void) viewDidLoad {[super viewDidLoad];} # click The pragma mark-listener button, computing Result // The controller defines a method and waits for the button on the interface to be called (implemented here)-(IBAction) btnClick :( UIButton *) sender {// Number of son controls in the view of the current controller member NSLog (@ "% d son controls in the view of the current controller member", self. view. subviews. count); // The tag of the calculated button is 4 if (4 = sender. tag) {NSLog (@ "click the calculation result button % @", sender); // 1. Name of the member variable starting with an underscore, 2, use the self point syntax // UITextField * textField1 = _ num1; NSString * n1 = self. num1.text; NSString * n2 = self. num2.text; NSLog (@ "1st digits: % @ 2nd digits: % @", n1, n2); int result = [n1 intValue] + [n2 intValue]; self. result. text = [NSString stringWithFormat: @ "% d", result];} switch ([sender tag]) {case 1: NSLog (@ "click the button with tag 1"); break; case 2: NSLog (@ "click the button with tag 2"); break; default: break ;} // BeyondViewController NSLog (@ "self is % @", self); [_ num1 resignFirstResponder]; [_ num2 resignFirstResponder];} @ end










Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.