0

DetailViewController .h および .m ファイルを作成しました。次に、ストーリーボードに UITableViewController を作成し、作成したファイルに接続しました。

次に、このコードを DetailViewController.m ファイルに追加しました。

#import "MasterViewController.h"
#import "DetailViewController.h"

// 1
#import "RageIAPHelper.h"
#import <StoreKit/StoreKit.h>

// 2
@interface MasterViewController () {
    NSArray *_products;
}
@end

@implementation MasterViewController

// 3
- (void)viewDidLoad
{
    [super viewDidLoad];

    self.title = @"In App Rage";

    self.refreshControl = [[UIRefreshControl alloc] init];
    [self.refreshControl addTarget:self action:@selector(reload) forControlEvents:UIControlEventValueChanged];
    [self reload];
    [self.refreshControl beginRefreshing];

}

// 4
- (void)reload {
    _products = nil;
    [self.tableView reloadData];
    [[RageIAPHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
        if (success) {
            _products = products;
            [self.tableView reloadData];
        }
        [self.refreshControl endRefreshing];
    }];
}

#pragma mark - Table View

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

// 5
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _products.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    SKProduct * product = (SKProduct *) _products[indexPath.row];
    cell.textLabel.text = product.localizedTitle;

    return cell;
}

@end

しかし、次のような行でコンパイル エラーが発生します。

self.refreshControl = [[UIRefreshControl alloc] init];

self.refreshControl が認識されていないと言っています。しかし、ファイルが UITableView ファイルの場合はどうすればよいのでしょうか?

編集:

これは.hです

//
//  DetailViewController.h
//  entrepreneur
//
//  Created by MacOSLion on 8/7/13.
//  Copyright (c) 2013 MacOSLion. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface DetailViewController : UITableViewController

@end
4

2 に答える 2

0

これを .h に追加します

 @property (weak, nonatomic) UIRefreshControl *refreshControl;
于 2013-08-07T23:57:50.783 に答える