我有一个表格视图,其中有很多项目 当我点击表格中的一个单元格时,它在web view中加载了一个视图,在viewdidload中的web视图中我有这个行代码来加载HTML文件至极是在项目文件将html文件加载到网页视图
NSString *name = pagename.text;
[WebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:name ofType:@"html"]isDirectory:NO]]];
从选定单元格与被称为测试的是Web视图推代码
if (indexPath.row == 0)
{
Test *test = [[Test alloc] initWithNibName:nil bundle:nil];
test.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:test animated:YES];
NSString *name1 = @"ba";
[[test pagename] setText:[NSString stringWithString:(NSString *)name1]];
}
else if (indexPath.row == 1)
{
Test *test = [[Test alloc] initWithNibName:nil bundle:nil];
test.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:test animated:YES];
NSString *name1 = @"bb";
[[test pagename] setText:[NSString stringWithString:(NSString *)name1]];
}
else if (indexPath.row == 2)
{
Test *test = [[Test alloc] initWithNibName:nil bundle:nil];
test.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:test animated:YES];
NSString *name1 = @"bc";
[[test pagename] setText:[NSString stringWithString:(NSString *)name1]];
}
的HTML文件被称为ba,bb,bc和bd .html
问题是当我选择表格中的四个单元格中的任意一个单元格时,它显示相同的html文件“ba.html”
我试过了一切,清理项目,删除文件并将其复制回来,改变了模拟器,重新启动了圈,甚至改变了文件名。
有帮助吗?
在此先感谢
更新:
这是孔代码
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
[[cell textLabel] setTextAlignment:UITextAlignmentRight];
cell.textLabel.text = [array objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:18];
cell.textLabel.numberOfLines = 3;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row == 0)
{
Test *test = [[Test alloc] initWithNibName:nil bundle:nil];
test.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:test animated:YES];
NSString *name1 = @"ba";
[[test pagename] setText:name1];
}
else if (indexPath.row == 1)
{
Test *test = [[Test alloc] initWithNibName:nil bundle:nil];
test.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:test animated:YES];
NSString *name1 = @"bb";
[[test pagename] setText:name1];
}
else if (indexPath.row == 2)
{
Test *test = [[Test alloc] initWithNibName:nil bundle:nil];
test.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:test animated:YES];
NSString *name1 = @"bc";
[[test pagename] setText:name1];
}
else if (indexPath.row == 3)
{
Test *test = [[Test alloc] initWithNibName:nil bundle:nil];
test.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:test animated:YES];
NSString *name1 = @"bd";
[[test pagename] setText:name1];
}
}
我添加了编码@PRNDL Development Studios – aLFaRSi 2012-04-11 18:01:44
编辑。试试看。 – 2012-04-11 18:18:32
仍然一样,没有任何变化 – aLFaRSi 2012-04-11 18:22:58