PFQueryTableViewController라는 구문 분석을 사용하여 클래스를 사용자 정의하려고합니다. 그래도 내 세포를 사용자 정의하고 싶지는 않습니다.UITableViewController는 사용자 정의하지 않습니다.
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithClassName:@"UserPhoto"];
self = [super initWithCoder:aDecoder];
if (self) {
// Custom the table
// The className to query on
self.parseClassName = @"UserPhoto";
// The key of the PFObject to display in the label of the default cell style
self.textKey = @"title";
// Whether the built-in pull-to-refresh is enabled
self.pullToRefreshEnabled = YES;
// Whether the built-in pagination is enabled
self.paginationEnabled = YES;
// The number of objects to show per page
self.objectsPerPage = 25;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self.tableView registerNib:[UINib nibWithNibName:@"FeedCustomCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"FeedCustom"];
}
#pragma mark - Parse
- (void)objectsDidLoad:(NSError *)error {
[super objectsDidLoad:error];
// This method is called every time objects are loaded from Parse via the PFQuery
}
- (void)objectsWillLoad {
[super objectsWillLoad];
// This method is called before a PFQuery is fired to get more objects
NSLog(@"Done");
}
// Override to customize what kind of query to perform on the class. The default is to query for
// all objects ordered by createdAt descending.
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
// If no objects are loaded in memory, we look to the cache first to fill the table
// and then subsequently do a query against the network.
if ([self.objects count] == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
[query orderByDescending:@"createdAt"];
NSLog(@"%@", query);
return query;
}
// Override to customize the look of a cell representing an object. The default is to display
// a UITableViewCellStyleDefault style cell with the label being the first key in the object.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
FeedCustomCell *cell = (FeedCustomCell *)[self.tableView dequeueReusableCellWithIdentifier:@"FeedCustom" forIndexPath:indexPath];
// Configure the cell
cell.caption.text = [object objectForKey:@"title"];
cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
아이디어가 있으십니까? FeedCustomCell은 IB를 사용하여 레이블을 추가하는 UITableViewCell의 하위 클래스입니다. 내 하위 클래스 PFQueryTableViewController에 대한 TableView도 IB를 통해 생성됩니다.