iphone - Custom Cell can't display in Table view in ios 6 -


#import "masterviewcontroller.h" #import "detailviewcontroller.h"  @interface masterviewcontroller () @end  @implementation masterviewcontroller   - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil   {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];      if (self) {           self.title = nslocalizedstring(@"master", @"master");     if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiompad) {         self.clearsselectiononviewwillappear = no;         self.contentsizeforviewinpopover = cgsizemake(320.0, 600.0);     }   }   return self;  }     - (void)dealloc    {       [_detailviewcontroller release];      [super dealloc];     }     - (void)viewdidload     {        [super viewdidload];       }      - (void)didreceivememorywarning      {          [super didreceivememorywarning];          // dispose of resources can recreated.       }         #pragma mark - table view          - (nsinteger)numberofsectionsintableview:(uitableview *)tableview          {                return 1;          }          - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section          {                 return 5;           }          -(cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath{       return 100.0;          }         // customize appearance of table view cells.         - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath        {              static nsstring *cellidentifier = @"customcell";              customcell *cell = (customcell *)[tableview dequeuereusablecellwithidentifier: cellidentifier];              if (cell == nil)           {                cell = [[[customcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease];            }      cell.celldate.text=@"date";      cell.celldescription.text =@"description";      cell.cellimageview.image = [uiimage imagenamed:@"facebook.png"];       cell.celltitle.text = @"title";       return cell;       }   - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath  {     if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone) {     if (!self.detailviewcontroller) {         self.detailviewcontroller = [[[detailviewcontroller alloc] initwithnibname:@"detailviewcontroller_iphone" bundle:nil] autorelease];     }        [self.navigationcontroller pushviewcontroller:self.detailviewcontroller animated:yes]; }     else    {     }   }  @end 

.h file

    #import <uikit/uikit.h>     #import "customcell.h"     #import "xmlstringfile.h"    @class detailviewcontroller;   @interface masterviewcontroller : uitableviewcontroller{    }   @property (strong, nonatomic) detailviewcontroller *detailviewcontroller;  @property(strong,nonatomic)customcell *customcell;   @end 

customcell.h


  #import <uikit/uikit.h>    @interface customcell : uitableviewcell{     iboutlet uiimageview *cellimageview;    iboutlet uilabel *celltitle;     iboutlet uilabel *celldescription;    iboutlet uilabel *celldate;   }  @property (retain, nonatomic) iboutlet uiimageview *cellimageview;  @property (retain, nonatomic) iboutlet uilabel *celltitle;  @property (retain, nonatomic) iboutlet uilabel *celldescription;  @property (retain, nonatomic) iboutlet uilabel *celldate;   @end 

customcell.m


      #import "customcell.h"        @implementation customcell      @synthesize celldate;    @synthesize celldescription;      @synthesize cellimageview;  @synthesize celltitle;   - (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier { self = [super initwithstyle:style reuseidentifier:reuseidentifier]; if (self) {     // initialization code } return self; }  - (void)setselected:(bool)selected animated:(bool)animated  { [super setselected:selected animated:animated];  // configure view selected state }  - (void)dealloc {     [super dealloc];  } @end 

this both class here problem in tableview data of customcell cant display onlt white screen. here work in ios masterdetails view template.. here have added m file in compile source customcell.xib size 300x100 here output xib file below this customcell.xib

this output screen

please me solve problem

 if(cell == nil)  {      nsarray *outlets = [nsarray arraywitharray:[[nsbundle mainbundle] loadnibnamed:@"customcell" owner:self options:nil]];      for(id obj in outlets)      {          if([obj iskindofclass:[uitableviewcell class]])          {              cell = (customcell *)obj;          }      }  } 

if customcell made via xib write code cell nil.

edit:-
may cause - think haven't changed customcell's class name. follow these steps -

  1. take xib name customcell.xib delete view.
  2. take uitableviewcell , set height , structure according you.
  3. select file's owner , change class name customcell, same thing uitableviewcell... select , change class name customcell.
  4. now connect subview's iboutlets.

note:- select iboutlets right clicking on uitableviewcell not file's owner.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -