Xcode 在iOS中基于表的视图中获取编译错误
我的RootViewController.m文件中出现编译错误。代码如下:Xcode 在iOS中基于表的视图中获取编译错误,xcode,Xcode,我的RootViewController.m文件中出现编译错误。代码如下: #import "RootViewController.h" @RootViewController的实现 布拉格标记- pragma标记视图生命周期 /* -(无效)viewDidLoad{ [超级视图下载] // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
#import "RootViewController.h"
@RootViewController的实现
布拉格标记-
pragma标记视图生命周期
/*
-(无效)viewDidLoad{
[超级视图下载]
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
*/
/*
-(无效)视图将显示:(BOOL)动画{
[超级视图将显示:动画];
}
/
/
-(无效)视图显示:(BOOL)动画{
[超级视图显示:动画];
}
/
/
-(无效)视图将消失:(BOOL)已设置动画{
[超级视图将消失:动画];
}
/
/
-(无效)视图消失:(BOOL)已设置动画{
[超级视窗消失:动画];
}
*/
/*
//替代以允许默认纵向方向以外的方向。
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation{
//对于支持的方向,返回YES。
返回(interfaceOrientation==UIInterfaceOrientationGraphic);
}
*/
布拉格标记-
pragma标记表视图数据源
//自定义表视图中的节数。
-(NSInteger)表格视图中的节数:(UITableView*)表格视图{
返回1;
}
//自定义表视图中的行数。
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节{
返回1;
}
//自定义表格视图单元格的外观。
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
[cell.textLabelSetText@"Hello World!"];
return cell;
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
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.
}
}
/*
//替代以支持表视图的条件编辑。
-(BOOL)tableView:(UITableView*)tableView caneditrowatinexpath:(nsindepath*)indepath{
//如果不希望指定的项可编辑,则返回“否”。
返回YES;
}
*/
/*
//替代以支持编辑表格视图。
-(void)tableView:(UITableView*)tableView提交的编辑样式:(UITableViewCellEditingStyle)行的编辑样式索引路径:(NSIndexPath*)索引路径{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
[cell.textLabelSetText@"Hello World!"];
return cell;
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
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.
}
}
*/
/*
//替代以支持重新排列表视图。
-(void)tableView:(UITableView*)tableView移动rowatinexpath:(nsindepath*)从indepath到indepath:(nsindepath*)到indepath{
}
*/
/*
//重写以支持表视图的条件重新排列。
-(BOOL)tableView:(UITableView*)tableView可以移动rowatinexpath:(nsindepath*)indepath{
//如果不希望该项目可重新订购,则返回“否”。
返回YES;
}
*/
布拉格标记-
pragma标记表视图委托
- (void)tableView:(UITableView*)tableView未选择RowatineXpath:(NSIndexPath*)indexPath{
static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } [cell.textLabelSetText@"Hello World!"]; return cell;
/* *detailViewController=[[alloc]initWithNibName:@“bundle:nil]; // ... //将选定对象传递给新的视图控制器。 [self.navigationController pushViewController:detailViewController动画:是]; [详细视图控制器发布]; */ }if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the row from the data source. [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } 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. }
- (无效)未收到记忆警告{ //如果视图没有superview,则释放该视图。 [超级记忆警告] //放弃所有未使用的缓存数据、图像等的所有权。 }
- (无效)视图卸载{ //放弃可在viewDidLoad或按需重新创建的任何内容的所有权。 //例如:self.myOutlet=nil; }
- (无效)解除锁定{ [super dealoc]; }
你能告诉我怎么了吗?TIA您应该添加冒号
:
[cell.textLabelSetText:@"Hello World!"];
但事实上应该是这样
[cell.textLabel setText:@"Hello World!"];
…或使用新的点表示法
cell.textLabel.text = @"Hello World!";