objective-c - TableView 不显示来自 Parse.com 的数据

标签 objective-c uitableview cocoa parse-platform

在我的 View Controller 中,我刚刚添加了一个 TableView 。 我在 file.h 和 file.m 中输入了所有代表。 即使在 Storyboard中,单元的标识也已正确输入,并且自定义单元已连接到我创建的单元 ch 自定义类。

现在我输入这段代码(使用 Parse.com)不会出现任何类型的错误,代码总是 super 干净,但是当我去运行时,表不会向我显示任何数据,就好像它已连接一样如果没有重用标识符,则将其添加到单元格或作为自定义类,而是执行了这两个步骤...我不明白为什么我看不到任何内容...您能找出错误是什么吗?

# import " FFFriendInAttesa.h "
# import " FFCustomCellFriendInAttesa.h "

@ interface FFFriendInAttesa ()    
@ end    
@ implementation FFFriendInAttesa


- (Void) viewDidLoad
{
    [super viewDidLoad ] ;
    self.FFTableView.delegate = self ;
    self.FFTableView.dataSource = self ;
    [self QueryForTableView ] ;
}


- ( NSInteger ) numberOfSectionsInTableView : ( UITableView * ) tableView
{
    return 1;
}

- ( NSInteger ) tableView : ( UITableView * ) tableView numberOfRowsInSection : ( NSInteger ) section {
    return [ self.UtentiInAttesa count] ;       
     }

- (void) { QueryForTableView
    
    PFQuery QueryForUserClass * = [ PFUser query ] ;
    [ QueryForUserClass findObjectsInBackgroundWithBlock : ^ ( NSArray * objects , NSError * error ) {
        if ( error) {
            self.UtentiInAttesa = objects ;
            NSLog ( @ " start query : % @ " , self.UtentiInAttesa ) ;
        }
    } ] ;
    [ self.FFTableView reloadData ] ;
}


- ( UITableViewCell * ) tableView : ( UITableView * ) tableView cellForRowAtIndexPath : ( NSIndexPath * ) indexPath
{
    static NSString * CellIdentifier = @ " CellaAmici " ;
    FFCustomCellFriendInAttesa * cell = [ self.FFTableView dequeueReusableCellWithIdentifier : CellIdentifier forIndexPath : indexPath ] ;
    if ( cell) {
        cell = [ [ FFCustomCellFriendInAttesa alloc ] initWithStyle : UITableViewCellStyleDefault reuseIdentifier : @ " CellaAmici "] ;
    }
        PFObject * user = [ self.UtentiInAttesa objectAtIndex : indexPath.row ] ;
        cell.FFNomeFriendLabel.text = [user objectForKey : FF_USER_NOMECOGNOME ] ;
          
    return cell ;
}

@ end

文件.h

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>

@interface FFFriendInAttesa : UIViewController <UITableViewDataSource, UITableViewDelegate>

@property (strong, nonatomic) IBOutlet UITableView *FFTableView;
@property (strong, nonatomic) NSArray *UtentiInAttesa;

@end

最佳答案

您的错误是您的 TableView 在其数据源更新之前刷新。你应该这样做:

- (void)QueryForTableView {
PFQuery QueryForUserClass * = [ PFUser query ] ;
[ QueryForUserClass findObjectsInBackgroundWithBlock : ^ ( NSArray * objects , NSError * error ) {
    // You put a wrong condition, objecs only returned when no error.
    if (!error) {
        self.UtentiInAttesa = objects ;
        NSLog ( @ " start query : % @ " , self.UtentiInAttesa ) ;
        // Refresh your tableview here
         [ self.FFTableView reloadData ] ;
    }
} ] ;

}

关于objective-c - TableView 不显示来自 Parse.com 的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19578939/

相关文章:

IOS/Objective-c : Access a ViewController with a button, "opposing" Storyboard结构

ios - UITabBarController 中的 UISearchController 不响应触摸

ios ARC 表访问错误

objective-c - 如何在 Objective-C++ 中返回 C++ 指针

objective-c - 在 NSMutableArray 中存储 float 会产生意想不到的结果

ios - Sprite Kit - 为多个场景定义变量

objective-c - NSWindow,按下 ENTER 键 : how to limit the key listening to the focused NSControl?

iphone - 检查 View 是否在运行时加载

ios - 展开 UITableViewCell

macos - 在 Cocoa 应用程序中捕获 Capslock 按键