Iphone 有关UITableViewController的简单问题
Iphone 有关UITableViewController的简单问题,iphone,objective-c,uitableview,Iphone,Objective C,Uitableview,UITableViewController不再自动滚动 如果UITableViewController单元格中的文本字段会被键盘模糊,如果该字段接收到焦点,则UITableViewController会将该字段滚动(或应该滚动)到可见区域。我有一个简单的UITableViewController在一个简单的UITableViewController中,我在UITableViewController中所做的更改是背景色和节头视图。。。有什么想法吗?这是代码…;) // //阿塔昔福涅 //快速出租
UITableViewController
不再自动滚动
如果UITableViewController
单元格中的文本字段会被键盘模糊,如果该字段接收到焦点,则UITableViewController
会将该字段滚动(或应该滚动)到可见区域。我有一个简单的UITableViewController
在一个简单的UITableViewController
中,我在UITableViewController
中所做的更改是背景色和节头视图。。。有什么想法吗?这是代码…;)
//
//阿塔昔福涅
//快速出租车
//
//保罗·费雷拉于2010年11月5日创作。
//版权所有2010 MobileLifeUtils.com。版权所有。
//
#进口
@接口请求AxiPhone:UITableViewController{
NSArray*Agruposcamposolicitacao;
}
@结束
//
//阿塔克西phone.m
//快速出租车
//
//保罗·费雷拉于2010年11月5日创作。
//版权所有2010 MobileLifeUtils.com。版权所有。
//
#导入“requestataxiphone.h”
#进口
@阿塔昔酮的实现
#布拉格标记-
#杂注标记初始化
-(id)initWithStyle:(UITableViewStyle)样式{
//Override initWithStyle:如果以编程方式创建控制器并希望执行不适合viewDidLoad的自定义。
self=[super initWithStyle:style];
self.title=@“律师Táxi”;
self.navigationItem.title=@“律师Táxi”;
//[self.tableView setBackgroundColor:[UIColor blackColor]];
UITextField*tfOrigem=[UITextField new];
[tfOrigem设置帧:CGRectMake(10.0f、10.0f、240.0f、25.0f)];
[t编辑时设置ClearButtonMode:UITextFieldViewMode];
[tfOrigem setAutocorrectionType:UITextAutocorrectionTypeNo];
[tfOrigem setAutocapitalizationType:UITextAutocapitalizationTypeWords];
[tfOrigem setReturnKeyType:UIReturnKeyDone];
UIButton*btLocalizacaoAtual=[UIButton按钮类型:UIButtonTypeRondRect];
[BTLocalizao ATUAL设定帧:CGRectMake(250.0f、1.0f、40.0f、40.0f)];
[BTLocalizaoAtual设置标题:@“GPS”表示状态:UIControlStateNormal];
NSArray*aCamposOrigem=[NSArray arrayWithObjects:tfOrigem,btLocalizaoAtual,nil];
NSDictionary*dCamposOrigem=[NSDictionary Dictionary WithObjects:[NSArray arrayWithObjects:@“Endereço de Origem”,aCamposOrigem,无]
forKeys:[NSArray数组,其对象:@“titulo”,“components”,无]
];
UITextField*tfComplemento=[UITextField new];
[TFO设置框架:CGRectMake(10.0f、10.0f、280.0f、25.0f)];
[TFC设置ClearButtonMode:UITextFieldViewModewhileEdit];
[TFO setAutocorrectionType:UITextAutocorrectionTypeNo];
[TFO setAutocapitalizationType:UITextAutocapitalizationTypeWords];
[TFO setReturnKeyType:UIReturnKeyDone];
NSArray*acamposcompletemento=[NSArray数组及其对象:tfComplemento,nil];
NSDictionary*dCamposComplemento=[NSDictionary Dictionary WithObjects:[NSArray arrayWithObjects:@“Endereço补充”,AcampsComplemento,无]
forKeys:[NSArray数组,其对象:@“titulo”,“components”,无]
];
UITextField*tfDestino=[UITextField new];
[tfDestino设置帧:CGRectMake(10.0f、10.0f、240.0f、25.0f)];
[tfDestino setClearButtonMode:UITextFieldViewModeWhileEditing];
[tfDestino setAutocorrectionType:UITextAutocorrectionTypeNo];
[tfDestino setAutocapitalizationType:UITextAutocapitalizationTypeWords];
[tfDestino setReturnKeyType:UIReturnKeyDone];
//[tfDestino setDelegate:self];
UIButton*BTReverseodesTino=[UIButton按钮类型:UIButtonTypeRondRect];
[BTR设置帧:CGRectMake(250.0f、1.0f、40.0f、40.0f)];
[BTReversionSetTitle:@“RD”用于状态:UIControlStateNormal];
NSArray*aCamposDestino=[NSArray阵列及其对象:tfDestino,btreversionodestino,nil];
NSDictionary*dCamposDestino=[NSDictionary Dictionary WithObjects:[NSArray arrayWithObjects:@“Endereço de Destino”,aCamposDestino,无]
forKeys:[NSArray数组,其对象:@“titulo”,“components”,无]
];
aGruposCamposSolicitacao=[[n包含对象的阵列:dCamposOrigem、dCamposComplemento、dCamposDestino、nil]retain];
回归自我;
}
#布拉格标记-
#pragma标记视图生命周期
/*
-(无效)viewDidLoad{
[超级视图下载];
//取消对以下行的注释,以在此视图控制器的导航栏中显示编辑按钮。
//self.navigationItem.rightBarButtonItem=self.editButtonItem;
}
*/
/*
-(无效)视图将显示:(BOOL)动画{
[超级视图将显示:动画];
}
*/
/*
-(无效)视图显示:(BOOL)动画{
[超级视图显示:动画];
}
*/
/*
-(无效)视图将消失:(BOOL)已设置动画{
[超级视图将消失:动画];
}
*/
/*
-(无效)视图消失:(BOOL)已设置动画{
[超级视窗消失:动画];
}
*/
/*
//替代以允许默认纵向方向以外的方向。
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation{
//对于支持的方向返回YES
返回(interfaceOrientation==UIInterfaceOrientationGraphic);
}
*/
#布拉格标记-
#pragma标记表视图数据源
-(NSInteger)表格视图中的节数:(UITableView*)表格视图{
//返回节数。
返回[Agruposcamposolicitacao计数];
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节{
//返回节中的行数。
返回1;
}
//自定义表格视图单元格的外观。
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
静态NSString*CellIdentifier=@”
//
// SolicitaTaxiPhone.h
// ExpressTaxi
//
// Created by Paulo Ferreira on 11/5/10.
// Copyright 2010 MobileLifeUtils.com. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SolicitaTaxiPhone : UITableViewController <UITextFieldDelegate> {
NSArray *aGruposCamposSolicitacao;
}
@end
//
// SolicitaTaxiPhone.m
// ExpressTaxi
//
// Created by Paulo Ferreira on 11/5/10.
// Copyright 2010 MobileLifeUtils.com. All rights reserved.
//
#import "SolicitaTaxiPhone.h"
#import <QuartzCore/QuartzCore.h>
@implementation SolicitaTaxiPhone
#pragma mark -
#pragma mark Initialization
- (id)initWithStyle:(UITableViewStyle)style {
// Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
self = [super initWithStyle:style];
self.title = @"Solicitar Táxi";
self.navigationItem.title = @"Solicitar Táxi";
//[self.tableView setBackgroundColor:[UIColor blackColor]];
UITextField *tfOrigem = [UITextField new];
[tfOrigem setFrame:CGRectMake(10.0f, 10.0f, 240.0f, 25.0f)];
[tfOrigem setClearButtonMode:UITextFieldViewModeWhileEditing];
[tfOrigem setAutocorrectionType:UITextAutocorrectionTypeNo];
[tfOrigem setAutocapitalizationType:UITextAutocapitalizationTypeWords];
[tfOrigem setReturnKeyType:UIReturnKeyDone];
UIButton *btLocalizacaoAtual = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btLocalizacaoAtual setFrame:CGRectMake(250.0f, 1.0f, 40.0f, 40.0f)];
[btLocalizacaoAtual setTitle:@"GPS" forState:UIControlStateNormal];
NSArray *aCamposOrigem = [NSArray arrayWithObjects:tfOrigem, btLocalizacaoAtual, nil];
NSDictionary *dCamposOrigem = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Endereço de Origem", aCamposOrigem, nil]
forKeys:[NSArray arrayWithObjects:@"titulo", @"componentes", nil]
];
UITextField *tfComplemento = [UITextField new];
[tfComplemento setFrame:CGRectMake(10.0f, 10.0f, 280.0f, 25.0f)];
[tfComplemento setClearButtonMode:UITextFieldViewModeWhileEditing];
[tfComplemento setAutocorrectionType:UITextAutocorrectionTypeNo];
[tfComplemento setAutocapitalizationType:UITextAutocapitalizationTypeWords];
[tfComplemento setReturnKeyType:UIReturnKeyDone];
NSArray *aCamposComplemento = [NSArray arrayWithObjects:tfComplemento, nil];
NSDictionary *dCamposComplemento = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Complemento do Endereço", aCamposComplemento, nil]
forKeys:[NSArray arrayWithObjects:@"titulo", @"componentes", nil]
];
UITextField *tfDestino = [UITextField new];
[tfDestino setFrame:CGRectMake(10.0f, 10.0f, 240.0f, 25.0f)];
[tfDestino setClearButtonMode:UITextFieldViewModeWhileEditing];
[tfDestino setAutocorrectionType:UITextAutocorrectionTypeNo];
[tfDestino setAutocapitalizationType:UITextAutocapitalizationTypeWords];
[tfDestino setReturnKeyType:UIReturnKeyDone];
//[tfDestino setDelegate:self];
UIButton *btReversoDestino = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btReversoDestino setFrame:CGRectMake(250.0f, 1.0f, 40.0f, 40.0f)];
[btReversoDestino setTitle:@"RD" forState:UIControlStateNormal];
NSArray *aCamposDestino = [NSArray arrayWithObjects:tfDestino, btReversoDestino, nil];
NSDictionary *dCamposDestino = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Endereço de Destino", aCamposDestino, nil]
forKeys:[NSArray arrayWithObjects:@"titulo", @"componentes", nil]
];
aGruposCamposSolicitacao = [[NSArray arrayWithObjects:dCamposOrigem, dCamposComplemento, dCamposDestino, nil] retain];
return self;
}
#pragma mark -
#pragma mark View lifecycle
/*
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
*/
/*
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
*/
/*
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
*/
/*
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
*/
/*
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
#pragma mark -
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return [aGruposCamposSolicitacao count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 1;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
NSArray *aCamposSecao = [[aGruposCamposSolicitacao objectAtIndex:indexPath.section] valueForKey:@"componentes"];
for (id componenteAtual in aCamposSecao) {
[cell.contentView addSubview:componenteAtual];
}
return cell;
}
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 50;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *vwTitulo = [[UILabel alloc] init];
[vwTitulo setBackgroundColor:[UIColor clearColor]];
UIView *vwBackgroundTitulo = [[UIView alloc] initWithFrame:CGRectMake(10.0f, 10.0f, 300.0f, 30.0f)];
[vwBackgroundTitulo setBackgroundColor:[UIColor yellowColor]];
vwBackgroundTitulo.layer.cornerRadius = 10.0f;
UILabel *lblTitulo = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 00.0f, 300.0f, 28.0f)];
[lblTitulo setBackgroundColor:[UIColor clearColor]];
[lblTitulo setTextColor:[UIColor blackColor]];
[lblTitulo setTextAlignment:UITextAlignmentCenter];
[lblTitulo setFont:[UIFont boldSystemFontOfSize:18.0f]];
[lblTitulo setText:[[aGruposCamposSolicitacao objectAtIndex:section] valueForKey:@"titulo"]];
[vwBackgroundTitulo addSubview:lblTitulo];
[vwTitulo addSubview:vwBackgroundTitulo];
return vwTitulo;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
*/
}
#pragma mark -
#pragma mark UITextFieldDelegate
- (void)textFieldDidBeginEditing:(UITextField *)textField {
NSLog(@"Chamou essa jossa!");
UITableViewCell *cell = (UITableViewCell*) [[textField superview] superview];
[self.tableView scrollToRowAtIndexPath:[self.tableView indexPathForCell:cell] atScrollPosition:UITableViewScrollPositionTop animated:YES];
[self isFirstResponder];
}
#pragma mark -
#pragma mark Memory management
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Relinquish ownership any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
// For example: self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end