Sunday 15 March 2015

ios - Customizing cells in nib so they are not static -



ios - Customizing cells in nib so they are not static -

i trying customize uitableview cells , have done without problems before using storyboard. doing using xib file. reason cannot alter cells "custom" cells not static. simple things numberofcells methods don't work because can't create cells custom. in storyboard "delete" cells or alter them can't select cell in nib file!

i can't find way , using storyboards not alternative @ point. code below, thanks!

#import "youtubeviewcontroller.h" #import "youtubecell.h" @interface youtubeviewcontroller () @end @implementation youtubeviewcontroller - (void)viewdidload { [super viewdidload]; // additional setup after loading view nib. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } -(bool)tableview:(uitableview *)tableview caneditrowatindexpath:(nsindexpath *)indexpath { homecoming no; } -(bool)tableview:(uitableview *)tableview canmoverowatindexpath:(nsindexpath *)indexpath { homecoming no; } -(uitableviewcelleditingstyle)tableview:(uitableview *)tableview editingstyleforrowatindexpath:(nsindexpath *)indexpath { homecoming uitableviewcelleditingstylenone; } - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { homecoming 88; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { homecoming 1; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { nsstring *reuseidentifier = @"youtubecell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:reuseidentifier]; if (cell == nil) { cell = [[[nsbundle mainbundle] loadnibnamed:@"youtubecell" owner:nil options:nil] objectatindex:0]; } //set cell homecoming cell; // [[cell authorname] settext:@"collin ruffenach"]; // [[cell articlename] settext:@”test article 1″]; // [[cell date] settext:@”may 5th, 2009″]; // [[cell imageview] setimage:[uiimage imagenamed:@"1.png"]]; } /* #pragma mark - navigation // in storyboard-based application, want little preparation before navigation - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { // new view controller using [segue destinationviewcontroller]. // pass selected object new view controller. } */ @end

it turns out needed set delegate , datasource command clicking uitableview "files owner". worked after that!

ios objective-c xcode uitableview

No comments:

Post a Comment