ios - Not sure how to set up a UITableViewController -
i created detailviewcontroller .h , .m files. created uitableviewcontroller in storyboard , connected files made.
then added code detailviewcontroller.m file:
#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
but compile errors on lines this:
self.refreshcontrol = [[uirefreshcontrol alloc] init];
saying self.refreshcontrol not recognized. how can if file uitableview file?
edit:
this .h
// // detailviewcontroller.h // entrepreneur // // created macoslion on 8/7/13. // copyright (c) 2013 macoslion. rights reserved. // #import <uikit/uikit.h> @interface detailviewcontroller : uitableviewcontroller @end
i think have mistake somewhere...
see, show implementation of :
@implementation masterviewcontroller
but definition of :
@interface detailviewcontroller : uitableviewcontroller
that's why, of course, can't find refreshcontrol in masterviewcontroller : property of uitableviewcontroller, of detailviewcontroller.
please tell me if it's not clear you.
Comments
Post a Comment