键盘216+35 0.35 0.25
#import" cTableViewController.h"
//UITextFieldDelegate导入UITextField代理,使用代理绑定的方法,BOOL类型
@interface cTableViewController() {
UIView * view;
}
@end
@implementation cTableViewController
-(void)dealloc {
[view release];
[super dealloc];
}
- (void)viewDidLoad {
[super viewDidLoad];
//注册cell
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
//self.tableView.bounces = NO;
//清除tableView的行线条
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//定义tableView的背景图片
UIView * backgroundView = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds] ] autorelease];
//backgroundView tableView的属性
self.tableView.backgroundView = backgroundView;
UIImageView * image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
image.image= [UIImage imageNamed:@"5.jpg"];
//添加到属性视图上
[self.tableView.backgroundView addSubview:image];
[image release];
//自定义view来做动画移动
view = [[UIView alloc] initWithFrame:CGRectMake(0, 440, 320, 40)];
view.backgroundColor = [UIColor lightGrayColor];
[self.tableView addSubview:view];
UITextField * tf = [[UITextField alloc] initWithFrame:CGRectMake(10, 2, 250, 36)];
tf.backgroundColor= [UIColor whiteColor];
//tf.layer.masksToBounds = 3;
//设置代理
tf.delegate =self;
//总清除按钮
tf.clearButtonMode = UITextFieldViewModeWhileEditing;
//边框样式
tf.borderStyle = UITextFieldViewModeAlways;
//点击return让键盘下去UIControlEventEditingDidEndOnExit结束编辑,键盘下落
[tf addTarget:selfaction:@selector(KeybordDown) forControlEvents:UIControlEventEditingDidEndOnExit];
[viewa ddSubview:tf];
[tf release];
UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(260, 0, 60, 40)];
[btn setTitle:@"发送" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[view addSubview:btn];
[btn release];
}
//键盘下落之后的操作动画
-(void)KeybordDown {
//view下落
[UIView animateWithDuration:0.25animations:^{
view.frame = CGRectMake(0, 440, 320, 40);
} ];
}
//UITextField的代理方法
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
//view上来
[UIView animateWithDuration:0.35animations:^{
view.frame =CGRectMake(0, 480-252-40, 320, 40);
} ];
return YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 0;
}
- (NSInteger)tableView:(UITableView * )tableView numberOfRowsInSection:(NSInteger)section {
return0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
// if (!cell) {
// cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
// }
// Configure the cell...
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return [[UIScreen mainScreen] bounds].size.height;
}
@end