不管我尝试什么,我似乎都无法通过使用 PFQueryTableViewController 更改 UITableView。我添加了代码,回顾了代码,摆脱了代码,从 UITableView 更改后,这一切似乎都抛出了同样的错误,我得到 *由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:'-[UITableViewController loadView]加载了“2-view-3”笔尖,但没有得到 UITableView。
我只是想从 PARSE 中填充一个表,基本的东西,但我只是想用我有限的能力帮助我的弟弟。任何帮助将非常感激
这是一些代码。我已经链接到我的 appdelegate 中的解析,一切都很好。我测试过。
视图控制器.h
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface BaliPartyViewController : PFQueryTableViewController
@end
视图控制器.m
#import "BaliPartyViewController.h"
#import "PartyDetailViewController.h"
#import "CustomCell.h"
@interface BaliPartyViewController ()
@end
@implementation BaliPartyViewController {
}
- (id)initWithCoder:(NSCoder *)aCoder
{
self = [super initWithCoder:aCoder];
if (self) {
// The className to query on
self.parseClassName = @"Recipe";
// The key of the PFObject to display in the label of the default cell style
self.textKey = @"name";
// 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 = @"CustomCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
// Configure the cell
PFFile *thumbnail = [object objectForKey:@"imageFile"];
PFImageView *thumbnailImageView = (PFImageView*)[cell viewWithTag:100];
thumbnailImageView.image = [UIImage imageNamed:@"placeholder.jpg"];
thumbnailImageView.file = thumbnail;
[thumbnailImageView loadInBackground];
UILabel *nameLabel = (UILabel*) [cell viewWithTag:101];
nameLabel.text = [object objectForKey:@"name"];
UILabel *prepTimeLabel = (UILabel*) [cell viewWithTag:102];
prepTimeLabel.text = [object objectForKey:@"prepTime"];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == self.searchDisplayController.searchResultsTableView) {
[self performSegueWithIdentifier: @"showPartyDetail" sender: self];
}
}
/*- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showPartyDetail"]) {
PartyDetailViewController *destViewController = segue.destinationViewController;
NSIndexPath *indexPath = nil;
if ([self.searchDisplayController isActive]) {
indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
destViewController.partyName = [searchResults objectAtIndex:indexPath.row];
destViewController.partyDate = [searchResults objectAtIndex:indexPath.row];
destViewController.information = [searchResults objectAtIndex:indexPath.row];
destViewController.location = [searchResults objectAtIndex:indexPath.row];
} else {
indexPath = [self.tableView indexPathForSelectedRow];
destViewController.partyName = [parties objectAtIndex:indexPath.row];
destViewController.partyDate = [partyTime objectAtIndex:indexPath.row];
destViewController.information = [information objectAtIndex:indexPath.row];
destViewController.location = [location objectAtIndex:indexPath.row];
destViewController.photo = [detailPicture objectAtIndex:indexPath.row];
}
// Hide bottom tab bar in the detail view
destViewController.hidesBottomBarWhenPushed = YES;
}
}*/
@end