Xcode_7 iOS_9 静态表 Objective-C (12)

来源:互联网 发布:圣人 知乎 编辑:程序博客网 时间:2024/06/06 15:38

1、新建SingleViewApplication项目,在storyboard面板把ViewController删掉,从控件拖一个TableViewController,接下来如图配置:






2、上面是第一个单元格的设计,2,3单元格分别添加按钮和标签,其中第三个单元格:





3、添加约束,都是自动添加就可以:




4、代码如下:

////  ViewController.h//  TestProject////  Created by 侯家奇 on 16/8/17.//  Copyright © 2016年 侯家奇. All rights reserved.//#import <UIKit/UIKit.h>@interface ViewController : UITableViewController@property (weak, nonatomic) IBOutlet UITextField *txtUserName;@property (weak, nonatomic) IBOutlet UITextField *txtPwd;- (IBAction)login:(id)sender;@end

////  ViewController.m//  TestProject////  Created by 侯家奇 on 16/8/17.//  Copyright © 2016年 侯家奇. All rights reserved.//#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}- (IBAction)login:(id)sender {    if ([self.txtUserName.text isEqual:@"busymonkey"] && [self.txtPwd.text isEqual:@"123456"]) {        NSLog(@"登录成功");        [self.txtPwd resignFirstResponder];//取消键盘第一响应        [self.txtUserName resignFirstResponder];    }}@end


0 0
原创粉丝点击