Ios 从Plist到详细视图控制器的URL';s Web视图

Ios 从Plist到详细视图控制器的URL';s Web视图,ios,objective-c,xcode,url,plist,Ios,Objective C,Xcode,Url,Plist,我有一个乐队应用程序,其中的应用程序需要有仪器规模上。为了做到这一点,我试图有一个PList文件的规模和名称的描述。我已经研究过了,我能找到的只是传递图片,而不是URL。我已经做完了。以下是其中的一部分: 我还有一个表视图,可以获取Plist文件的名称和比例部分 我不知道该怎么做,我该如何深入到详细视图控制器,然后将单击的表视图单元格的URL加载到UI Webview中,以下是主表视图的.m中的代码: #import "TableViewController.h" #import "Deta

我有一个乐队应用程序,其中的应用程序需要有仪器规模上。为了做到这一点,我试图有一个PList文件的规模和名称的描述。我已经研究过了,我能找到的只是传递图片,而不是URL。我已经做完了。以下是其中的一部分:

我还有一个表视图,可以获取Plist文件的名称和比例部分

我不知道该怎么做,我该如何深入到详细视图控制器,然后将单击的表视图单元格的URL加载到UI Webview中,以下是主表视图的.m中的代码:

#import "TableViewController.h"
#import "DetailView.h"
@interface TableViewController ()
@end

@implementation TableViewController
@synthesize content = _content;

-(NSArray *)content
{
    if (!_content) {
        _content = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Scales" ofType:@"plist"]];
    }
return _content;
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"Detail"])
    {
        // Get reference to the destination view controller
    }
}

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
    // Custom initialization
    }
return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [self.content count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    cell.textLabel.text = [[self.content objectAtIndex:indexPath.row] valueForKey:@"Name"];
    cell.detailTextLabel.text = [[self.content objectAtIndex:indexPath.row] valueForKey:@"Scale"];

return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
 // ...
 // Pass the selected object to the new view controller.
 [self.navigationController pushViewController:detailViewController animated:YES];
  */
}

@end
#导入“TableViewController.h”
#导入“DetailView.h”
@接口TableViewController()
@结束
@TableViewController的实现
@合成内容=_内容;
-(NSArray*)内容
{
如果(!\u内容){
_内容=[[NSArray alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@“Scales”of type:@“plist”];
}
返回内容;
}
-(void)prepareForSegue:(UIStoryboardSegue*)segue发送方:(id)发送方{
//确保故事板中的序列名称与此行相同
if([[segue identifier]IsequalString:@“Detail”])
{
//获取对目标视图控制器的引用
}
}
-(id)initWithStyle:(UITableViewStyle)样式
{
self=[super initWithStyle:style];
如果(自我){
//自定义初始化
}
回归自我;
}
-(无效)viewDidLoad
{
[超级视图下载];
//取消对下一行的注释以保留演示文稿之间的选择。
//self.clearselectiononviewwillappear=否;
//取消对以下行的注释,以在此视图控制器的导航栏中显示编辑按钮。
//self.navigationItem.rightBarButtonItem=self.editButtonItem;
}
-(无效)未收到记忆警告
{
[超级记忆警告];
//处置所有可以重新创建的资源。
}
#pragma标记-表视图数据源
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
//返回节中的行数。
返回[self.content count];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“Cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textlab.text=[[self.content objectAtIndex:indexath.row]valueForKey:@“Name”];
cell.detailtextlab.text=[[self.content objectAtIndex:indexath.row]valueForKey:@“Scale”];
返回单元;
}
-(void)tableView:(UITableView*)tableView未选择RowatineXpath:(NSIndexPath*)indexPath
{
//导航逻辑可能位于此处。创建并推送另一个视图控制器。
/*
*detailViewController=[[alloc]initWithNibName:@“bundle:nil];
// ...
//将选定对象传递给新的视图控制器。
[self.navigationController pushViewController:detailViewController动画:是];
*/
}
@结束
` 如果有人知道怎么做,请帮助我

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
 detailViewController.webLink = [[self.content objectAtIndex:indexPath.row] valueForKey:@"URL"];//webLink is NSStringProperty in DetailViewController.h
 [self.navigationController pushViewController:detailViewController animated:YES];
}
在ViewDid中加载UIWebView加载DetailViewController使用XIB

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.webLink]]];
}
关于如何推送到WebViewController,请参阅示例代码:

用故事板

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail"]) {
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
     NSString *webLink = [[self.content objectAtIndex:indexPath.row] valueForKey:@"URL"];//webLink is NSStringProperty in DetailViewController.h
        [[segue destinationViewController] setWebLink:webLink];
    }
}

这在故事板应用程序中是否有效。由于weblink部分不起作用,我理解这一点,我的问题是它现在说Indexpath是一个未声明的标识符。有人知道如何修复吗?它就在那里,我只是不知道如何传输URL。这是上面的一个副本:
-(void)prepareforsgue:(UIStoryboardSegue*)segue sender:(id)sender{//如果([[segue identifier]isEqualToString:@“Detail”]){//获取对目标视图控制器的引用},请确保脚本中的segue名称与此行相同
默认代码:nsindepath*indepath=[self.tableView indexPathForSelectedRow];现在显示的另一个问题是,
在DetailViewController类型的对象上找不到属性webLink
(在detail View controller.m文件中)。这是什么意思?