iphone - Problems making UITableView -


hi, i'm new xcode programming , i'm bit confused while creating uitableview.

i reading lots of tutorials , have created subclass of tableviewcontroller.

i have uiviewcontroller xib file containing uitableview inside.

i've implemented necessary methods in tableviewcontroller subclass don't know how display show tableview on screen.

i tried setting table delegate tableviewcontroller table doesn't show , it's linked iboutlet property on uitableview.

please tell me i'm doing wrong.

sorry bad english

edit: help

here code method:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cell";      uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];     if (cell == nil) {         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylevalue2 reuseidentifier:cellidentifier];     }     fichaitem * item = [sucursales objectatindex:indexpath.section];     cell.textlabel.text = [item.campos objectatindex:indexpath.row];     cell.detailtextlabel.text = [item.datos objectatindex:indexpath.row];     return cell; } 

i can't see what's wrong, code copied , modified show data.

there multiple ways achieve this.

way 1 (i'm doing way):

open viewcontroller.h , inherit uitableviewdelegate , uitableviewdatasource protocols. looks this: @interface viewcontroller : uiviewcontroller <uitableviewdelegate, uitableviewdatasource>

then open xib, drag uitableview object view , hook up: right-click-drag tableview file's owner object on left hand side. select delegate , redo datasource.

then need implement delegate methods. won't need subclass uitableviewcontroller

way 2

subclass uitableviewcontroller. drag uitableview view , add "object" xib. set class tableviewcontroller subclass , hook tableview.

there might exist several more ways it. these ways i'm familiar with.

edit: here example implementation of 1 delegate method.

nsarray *datasource = @[@{@"title": @"mytitle", @"subtitle": @"mysubtitle"}, @{@"title": @"some other title", @"subtitle": @"some explanation"}];  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"reusablecell"];      if (!cell) {         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:@"reusablecell"];     }      // datasource nsarray of nsdictionaries     [[cell textlabel] settext:[[datasource objectatindex:[indexpath row]] objectforkey:@"title"]];     [[cell detailtextlabel] settext:[[datasource objectatindex:[indexpath row]] objectforkey:@"subtitle"]];      return cell; } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -