所以我有一个包含多个项目的表视图控制器。一切都在运作,所以我独自离开了,并开始在我的项目中处理其他事情。当我在我的项目中完成其他提示并回到我的TableViewController上工作时,它无法正常工作。当我点击某个项目时,它不会转到下一页。
在PhotosTableViewController.m中我有这个:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"ShowPage"])
{
DisplayViewController *dvc = [segue destinationViewController];
NSIndexPath *path = [self.tableView indexPathForSelectedRow];
Photo *c = [photos objectAtIndex:path.row];
[dvc setCurrentPhoto:c];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// I load all my objects in my array here
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
//6 // Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [photos count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"PhotoCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
// Configure the cell...
Photo *current = [photos objectAtIndex:indexPath.row];
[cell.textLabel setText:[current name]];
NSString *details = [current notes];
if ([indexPath section] == 0)
{
[[cell detailTextLabel] setText:details];
}
else{
[[cell detailTextLabel] setText:@"it's not working"];
}
NSString *imageFile = [[NSBundle mainBundle] pathForResource:@"masjid" ofType:@"png"];
UIImage *myImg = [[UIImage alloc] initWithContentsOfFile:imageFile];
[[cell imageView] setImage:myImg];
return cell;
}
在我的DisplayViewController.m中,我有这个:
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *image = [UIImage imageNamed:[currentPhoto filename]];
[self.currentImage setImage: image];
[self setTitle:[currentPhoto name]];
[detailsLabel setText:[currentPhoto notes]];
}
- (void)viewDidUnload
{
[self setCurrentImage:nil];
[self setDetailsLabel:nil];
[self setCurrentPhoto:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
所以我认为当我在项目中处理其他问题而不关注我的表视图控制器时会出现问题。我已经解析了代码,没有解决方案。我很抱歉要查看一些代码,但就我而言,我已尽力而为,我需要继续前进。
感谢所有帮助,谢谢