我试图让我的 plist 库中每个项目的标签和图像显示在我的详细信息选项卡中。
这是我的 tableview 的图片,我可以让我的 plist 字典工作。一组图像和一个或多个项目。(例如第 0 项是 thermostat.jpg 和 Thermostat 标签。
这是单击单元格时详细视图的图片。它从单元格中提取标签和恒温器的图像。
但是,当单击 plist(厕所)中的第 1 项时,它会拉出厕所名称,但仍会显示恒温器图像。像这样。
这是我的 detailviewcontroller 代码
.h
#import <Foundation/Foundation.h>
@interface DetailViewController : UIViewController
{
IBOutlet UIScrollView *scrollView;
}
@property (nonatomic, strong) IBOutlet UILabel *itemLabel;//Name of that view
@property (nonatomic, strong) NSString *itemName;
@property (nonatomic, strong) IBOutlet UIImageView *myImageView; //Image View
@property (strong, nonatomic) IBOutlet UILabel *myTextView; //Description View
@end
和.m
#import "DetailViewController.h"
@interface DetailViewController ()
@end
@implementation DetailViewController
@synthesize itemLabel;
@synthesize itemName;
@synthesize myImageView;
@synthesize myTextView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
itemLabel.text = itemName;
//**************SCROLL VIEW*************
[scrollView setScrollEnabled:YES];
[scrollView setContentSize:CGSizeMake(320,960)];
scrollView.contentInset=UIEdgeInsetsMake(0.0,0.0,90.0,0.0);
////I know below this is the Problem, BUT im not sure what its supposed to be?////
NSDictionary *picturesDictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"repairlist" ofType:@"plist"]];
NSArray *imageArray = [picturesDictionary objectForKey:@"Thumbnail"];
myImageView.image = [UIImage imageNamed:[imageArray objectAtIndex:0]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
所以总而言之,我试图让图像在单击该单元格时正确显示
这是我使用的 plist 的图像:
我的 TableViewController 中已经有了这个
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"ItemListCell"]) {
DetailViewController *destViewController = segue.destinationViewController;
NSIndexPath *indexPath = nil;
if ([self.searchDisplayController isActive]) {
indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
destViewController.itemName = [searchResults objectAtIndex:indexPath.row];
} else {
indexPath = [self.myTableView indexPathForSelectedRow];
destViewController.itemName = [repairList objectAtIndex:indexPath.row];
//destViewController.textView = [descrip objectAtIndex:indexPath.row];
}
}
}