Iphone Tableview推送到不同的视图
我有一个代码,当按下一个单元格时,它会推到一个新的视图。此新视图根据所按单元格的名称更改其标题。但是,所有单元格的视图都是相同的,如果我在一个单元格下更改了某些内容,则会更改另一个单元格的视图。如何做到这一点,使每个单元格的每个视图都不同,而不创建视图负载;这是不切实际的。多谢各位 推送代码:Iphone Tableview推送到不同的视图,iphone,ios,xcode,Iphone,Ios,Xcode,我有一个代码,当按下一个单元格时,它会推到一个新的视图。此新视图根据所按单元格的名称更改其标题。但是,所有单元格的视图都是相同的,如果我在一个单元格下更改了某些内容,则会更改另一个单元格的视图。如何做到这一点,使每个单元格的每个视图都不同,而不创建视图负载;这是不切实际的。多谢各位 推送代码: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [self.tabl
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
ACollection *newView = [[ACollection alloc] init];
newView.template = [[Global collections] objectAtIndex:indexPath.row];
newView.theTitle = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text;
[self.navigationController pushViewController:newView animated:YES];
}
标题似乎是您在单元格选择上设置的局部变量。 但是,导航控制器在导航项中设置视图控制器的标题。 因此,您可以设置AVCollections标题,如tis:
newView.navigationItem.title = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text;
<> >在单元选择中。 嗯,现在考虑数组中的字符串。(数组项的数目等于单元格的数目。或者我们可以说,您正在从数组中加载细节)。 首先,在
didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Here we got the name of the item we are currently going to load
NSString *item_Name = [contentArray objectAtIndex: indexPath.row];
ViewController *yourViewController = [[ViewController alloc] initWithNIBName: @"ViewController" bundle: nil];
yourViewController.navigationItem.title = item_Name;
[self.navigationController pushViewController: yourViewController animated: YES];
}
或者像lukya说的你可以用
NSString *item_Name = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text;
如果要将单元本身的标题标签设置为局部视图的标题
希望这有帮助。您可以使用
NSString*mystring在第二个类(Acollection)中编写>并在didSelectRowAtIndexPath
中将其值赋值为newView.mystring=[self.tableView cellForRowAtIndexPath:indexath].textLabel.text代码>并在第二个视图中使用self.title=mystring
。