所以我有一个表视图连接到一个带有 url 的 plist。当我单击表格视图单元格时,我希望它带我进入详细视图,但现在唯一的问题是当我单击单元格带我进入详细视图时,它只会加载一个黑屏,上面什么都没有。我在编译器上没有收到任何错误,所以我不知道出了什么问题。我已重置刺激器并尝试重新启动计算机,但现在我开始认为代码有问题。有人可以帮忙吗?
表视图控制器.m
- (void)viewDidLoad {
[super viewDidLoad];
NSString *myListPath = [[NSBundle mainBundle] pathForResource:@"myList" ofType:@"plist"];
tableData = [[NSArray alloc]initWithContentsOfFile:myListPath];
NSLog(@"%@",tableData); }
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [tableData count]; }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if( cell == nil )
{
NSLog(@"Cell Creation");
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
}
//Set Data For each Cell
cell.textLabel.text = [[tableData objectAtIndex:indexPath.row]objectForKey:@"cellName"];
cell.detailTextLabel.text = [[tableData objectAtIndex:indexPath.row]objectForKey:@"cellSubtitle"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Index Selected,%d",indexPath.row);
WebViewController *View = [[WebViewController alloc] init];
NSString *urltoPass = [NSString stringWithString:[[tableData objectAtIndex:indexPath.row]objectForKey:@"cellSubtitle"]];
View.urlString = [[NSString alloc] initWithFormat:@"http://%@",urltoPass];
View.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:View animated:YES completion:nil];
}