segmented control控件
sender.selectedsegmentindex
switch 控件
sender.on sender.off
tableview控件
1.一般自己建一个不含xib的viewcontroller类
2.在tableviewcontroller类中进行表格配置
//这个配置的是需要连续的几个段
-
(NSInteger)numberOfSectionsInTableView:(UITableView
*)tableView
{
// Return the number of sections.
return 2;
}
//每个段需要几行
-
(NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the
section.
return 10;
}
-
(UITableViewCell
*)tableView:(UITableView
*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
//如果没有单元,创建单元
if (!cell) {
cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier]autorelease];
}
//单元输出的格式
cell.textLabel.text=[NSString stringWithFormat :@"第%d行",indexPath.row];
return cell;
}
3.在主文件中创建控制器呈现
a.首先要包含table控制器
b.
-(void)viewDidAppear:(BOOL)animated{
//create the tableview controller
testUITableViewController
*table=[[[testUITableViewController alloc]init]autorelease];
[self
presentModalViewController:table animated:YES];
}
4.tableview的基本属性
self.tableView.rowHeight=40;
cell.textLabel.textColor=[UIColor blueColor];
//这个属性要特别注意他的前提是cell初始化为initWithStyle:UITableViewCellStyleSubtitle
cell.detailTextLabel.text=@"aaaaa";
//这个是文字前的logo
cell.imageView.image=[UIImage imageNamed:@"1"];
//显示文字在列上面的距离差别
cell.indentationlevel=indexpath.row/10;
5.行委托部分
#pragma mark - Table view delegate
-
(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create
and push another view controller.
UIAlertView
*msgbox=[[[UIAlertView alloc]initWithTitle:@"提示"
message:[NSString stringWithFormat:@"你按下了第%d行",indexPath.row]delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles: nil]
autorelease];
[msgbox show];
}
//willdisplaycell委托方法
-(void)tableView:(UITableView *)tableView
willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath
*)indexPath
{
cell.backgroundColor=[UIColor yellowColor];
}
textfield 控件
//本控件主要讲述的要点是委托及跳出键盘后对键盘按键响应的方法以及对于first responser的应用
1,委托三要素
在h文件控制器旁边添加协议
在didload中指明delegate对象
应用委托中提供的方法
2,对于在本控件作为firstresponser时,我们要求放弃firstresponser权限的方法
-(void)PressReturn{
//if textfield control is the
firstresponder
if
([conText isFirstResponder]) {
[conText resignFirstResponder];
}
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self
PressReturn];
return YES;
}