-1

我正在关注这个关于如何运行 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
4

1 回答 1

0

FriendViewController.xib中,view从您的文件所有者到您的实际视图的连接要么断开连接,要么一开始就从未连接。UIViewController 不是成为朋友并为您加载视图,而是通过异常(漂亮)将您的应用程序关闭。

于 2013-01-10T02:11:56.940 回答