TableViewCell
イメージを作成します。私のplistからの画像値。どちらの方法が必要ですか?それはどうですか? それは私がtableviewcell
Image in TableviewCell
NSArray *brend =[brends objectAtIndex:indexPath.row];
NSString *logo = [[brend objectAtIndex:indexPath.row]valueForKey:@"Image"];
cell.imageView.image=[UIImage imageNamed:logo];
私のplistに画像を追加することにより、コードです:
<dict>
<key>Mercedec</key>
<dict>
<key>Image</key>
<string>Mercedes.png</string>
</dict>
<key>Rena</key>
<dict>
<key>Image</key>
<string>Renault.png</string>
</dict>
しかし、それは最近Objective-C
を学び始めたので
を墜落しました。誰か助けてくれますか?
EDIT:
@interface MainTableViewController()
@property (nonatomic, copy) NSDictionary *companylist;
@property (nonatomic, copy) NSArray *brends;
@end
@implementation MainTableViewController
@synthesize brends,companylist;
- (void)viewDidLoad {
[super viewDidLoad];
UITableView *tableView = (id)[self.view viewWithTag:1];
[tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
NSString *Stplist= [[NSBundle mainBundle] pathForResource:@"wunder" ofType:@"plist"];
companylist = [[NSDictionary alloc]initWithContentsOfFile:Stplist];
self.brends = [[self.companylist allKeys] sortedArrayUsingSelector:@selector(compare:)];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return brends.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.textLabel.text=brends[indexPath.row];
NSArray *imagesArray= [companylist allValues ];
NSString *logo= [[imagesArray objectAtIndex:indexPath.row]valueForKey:@"Image"];
cell.imageView.image=[UIImage imageNamed:logo];
return cell;
}
は、クラッシュログを投稿できますか?ブレンドは何ですか?あなたのplistに基づいてそれが辞書であると考えられている配列か辞書ですか? – Joshua
私はbrendが 'ブランド'だと思います - ブランドの車のように。 – headbanger
この画像はJsonから入手できますか?実際にPlistに保存したいのですか? – Arun