我正在关注如何运行FQL查询这个漂亮的教程(https://developers.facebook.com/docs/howtos/run-fql-queries-ios-sdk/)但不幸的是我遇到了一个意想不到的问题我不知道该怎么解决。我能够跟随拉数据并一直跟着直到第三步(实现它之后,程序崩溃)我已经通过我的程序只是为了看看我是否犯了错误但我没有看到任何错误。在这种情况下,有人可以给我一个关于我需要如何修理插座的建议吗?谢谢。
FriendViewController.h
#import <UIKit/UIKit.h>
@interface FriendViewController : UITableViewController
@property (strong, nonatomic) NSArray *data;
@end
FriendViewController.m
#import "FriendViewController.h"
@interface FriendViewController ()
@property (strong, nonatomic) UIToolbar *toolbar;
@end
@implementation FriendViewController
@synthesize data = _data;
@synthesize toolbar = _toolbar;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
// Add a toolbar to hold a Done button that will dismiss this view controller
self.toolbar = [[UIToolbar alloc] init];
self.toolbar.barStyle = UIBarStyleDefault;
[self.toolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self.toolbar sizeToFit];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(doneButtonPressed:)];
UIBarButtonItem *space = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
self.toolbar.items = [NSArray arrayWithObjects:space, doneButton, nil];
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [self.data count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [[self.data objectAtIndex:indexPath.row]
objectForKey:@"name"];
UIImage *image = [UIImage imageWithData:
[NSData dataWithContentsOfURL:
[NSURL URLWithString:
[[self.data objectAtIndex:indexPath.row]
objectForKey:@"pic_square"]]]];
cell.imageView.image = image;
return cell;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
*/
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
return self.toolbar;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return self.toolbar.frame.size.height;
}
- (void)doneButtonPressed:(id)sender
{
// Dismiss view controller based on supported methods
if ([self respondsToSelector:@selector(presentingViewController)]) {
// iOS 5+ support
[[self presentingViewController] dismissModalViewControllerAnimated:YES];
} else {
[[self parentViewController] dismissModalViewControllerAnimated:YES];
}
}
@end
答案 0 :(得分:0)
在FriendViewController.xib
中,从文件所有者到实际视图的view
连接已断开连接或从未连接过。 UIViewController不会成为朋友并为您加载视图,而是将您的应用程序排除在外(异常)。