我有一個表格視圖,其中有很多項目 當我點擊表格中的一個單元格時,它在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