我想填充自解析數據的自定義tableview。在這一點上,我可以連接我的數據和應用程序下載行,但標籤中的名稱和圖像存儲不會出現。填充自定義tableview與解析
我與引用網點
**CustomCell.h**
#import <UIKit/UIKit.h>
@interface CustomCellTableViewCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *autor;
@property (strong, nonatomic) IBOutlet UILabel *titulo;
@property (strong, nonatomic) IBOutlet UIImageView *myImage;
@end
**CustomCell.m**
#import "CustomCellTableViewCell.h"
@implementation CustomCellTableViewCell
@synthesize consola = _autor;
@synthesize titulo = _titulo;
@synthesize myImage = _myImage;
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
**ViewController.h**
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import <ParseUI/ParseUI.h>
@interface ViewController : PFQueryTableViewController
@end
**ViewContoller.m**
#import "ViewController.h"
#import "CustomCell.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (id)initWithCoder:(NSCoder *)aCoder
{
self = [super initWithCoder:aCoder];
if (self) {
// The className to query on
self.parseClassName = @"Libros";
// The key of the PFObject to display in the label of the default cell style
self.textKey = @"author";
// Whether the built-in pull-to-refresh is enabled
self.pullToRefreshEnabled = YES;
// Whether the built-in pagination is enabled
self.paginationEnabled = NO;
}
return self;
}
- (PFQuery *)queryForTable
{
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
return query;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
static NSString *simpleTableIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
// Configure the cell
PFFile *thumbnail = [object objectForKey:@"imagen"];
PFImageView *thumbnailImageView = (PFImageView*)[cell viewWithTag:100];
UILabel *titulo = (UILabel*) [cell viewWithTag:101];
titulo.text = [object objectForKey:@"titulo"];
UILabel *autor = (UILabel*) [cell viewWithTag:102];
consola.text = [object objectForKey:@"autor"];
return cell;
}
@end
我怎麼能顯示我在標籤和圖像數據連接與一個圖像和兩個標籤自定義單元格?
我是Xcode的初學者。
你不應該加載一個'UITableViewCell'到你的'UITableView'中,你應該加載你自定義的'UITableViewCell','CustomCellTableViewCell'。然後訪問它的屬性,你會......你不需要獲得一個指向標籤或圖像的指針,只需在命名它們時訪問屬性......另外,你應該有一個'PFImageView'公共屬性,而不是你自定義的'UITableViewCell'中的'UIImageView' – jsetting32