从表视图推送到包含选项卡栏的视图时,无法在 Web 视图中分配数据
我正在解析一个 json 对象并将其填充到表视图中。
当选择表视图行时,它会导航到名为“ThirdDetailView”的详细视图控制器,并且能够在我的 ThirdDetailView 中分配解析的数据(使用 Web 视图)。
当我的 ThirdDetailView 是四个选项卡栏中的视图之一时,就会出现问题。我已将这四个选项卡栏放置在名为firstView 的视图中,以便单击表视图导航到包含四个选项卡栏的firstView,显示ThirdDetailView 与第一个选项卡一样突出显示。如果是这种情况,数据不会加载到 Web 视图中。
下面是代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
title=[story objectAtIndex:indexPath.row];
NSDictionary *detaildesc1=[media1 objectAtIndex:indexPath.row];
ThirdDetailView *detailViewController1= [[ThirdDetailView alloc]init];
[detailViewController1 initWithItem:detaildesc1 Title:title];
FirstView *dvController4 = [[FirstView alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController4 animated:YES];
[dvController4 release];
[detailViewController1 release];
}
}
ThirdDetailView
@synthesize theItem1,theTitle,img,body,message,facebook,webview,id1;
- (id)initWithItem:(NSDictionary *)detaildesc1 Title:(NSString *)title
{
if (self = [super initWithNibName:@"ThirdDetailView" bundle:nil]) {
self.id1=detaildesc1;
self.theTitle=title;
urlAddress = [NSString stringWithFormat:@"http://dev-parkguiden.knutpunkten.se/Api/GetPark?parkid=%@",self.id1];
baseURL =[[NSURL URLWithString:urlAddress]retain];
jsonData=[NSData dataWithContentsOfURL:baseURL];
// self.title=title;
NSDictionary *items=[NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:nil];
boom=[items objectForKey:@"description"];
NSLog(@"what is the text:%@",[items objectForKey:@"description"]);
[self.webview loadHTMLString:boom baseURL:nil];
}
return self;
}
FirstView 标签栏
I'm parsing a json object and populating it in table view.
When the table view row is selected it navigates to a detailed view controller named as "ThirdDetailView" and was able to assign the parsed data in my ThirdDetailView (using web view).
Problem arises when my ThirdDetailView is one of the view in my four tab bars .I have placed those four tabbar in a view called firstView, So that clicking on the tableview navigates to firstView containing four tabbars showing the ThirdDetailView as highlighted as the first tab.if this is the case data is not getting loaded in the web view.
below is the code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
title=[story objectAtIndex:indexPath.row];
NSDictionary *detaildesc1=[media1 objectAtIndex:indexPath.row];
ThirdDetailView *detailViewController1= [[ThirdDetailView alloc]init];
[detailViewController1 initWithItem:detaildesc1 Title:title];
FirstView *dvController4 = [[FirstView alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController4 animated:YES];
[dvController4 release];
[detailViewController1 release];
}
}
ThirdDetailView
@synthesize theItem1,theTitle,img,body,message,facebook,webview,id1;
- (id)initWithItem:(NSDictionary *)detaildesc1 Title:(NSString *)title
{
if (self = [super initWithNibName:@"ThirdDetailView" bundle:nil]) {
self.id1=detaildesc1;
self.theTitle=title;
urlAddress = [NSString stringWithFormat:@"http://dev-parkguiden.knutpunkten.se/Api/GetPark?parkid=%@",self.id1];
baseURL =[[NSURL URLWithString:urlAddress]retain];
jsonData=[NSData dataWithContentsOfURL:baseURL];
// self.title=title;
NSDictionary *items=[NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:nil];
boom=[items objectForKey:@"description"];
NSLog(@"what is the text:%@",[items objectForKey:@"description"]);
[self.webview loadHTMLString:boom baseURL:nil];
}
return self;
}
FirstView Tabbar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个,
我在我的应用程序中测试过,可以在网络视图中完美显示您的文本
Try Out this
I have tested in my app in perfectly show your text in webview
嘿,我已使用给定的 URL
@"http://dev-parkguiden.knutpunkten.se/Api/GetPark?parkid=56"
尝试了您的代码,它显示在我的网页视图。
请检查您的
IBOUlet
是否已正确连接已编辑
嘿,在上面的代码中,您没有在
dvController4
中使用detailViewController1
。您刚刚分配了它,然后释放了它,但您还没有使用它。这可能是漏洞。Hey I have tried your code with the given URL
@"http://dev-parkguiden.knutpunkten.se/Api/GetPark?parkid=56"
and it's showing in my web view.
Please check that your
IBOulet
is connected properlyEdited
hey you haven't used
detailViewController1
indvController4
in the above code..You have just allocated it and then released it but you haven't used it.This might be the bug.