iphone - How to add UITableView in a customize view declared dynamically in iOS? -


in app,in navigation bar 1 button (say browsebutton) there , click button 1 view (say browseview) appears took dynamically of cgrectmake function.

i added uitableview (say browsetableview) in browseview.

table gets added browseview delegate methods not working.

please give me proper direction.

my code follows:

mainviewcontroller.h

@interface mainviewcontroller : uimainviewcontroller <uitableviewdelegate,uitableviewdatasource>   

mainviewcontroller.m

browsetableview.delegate = self; browsetableview.datasource =self;  -(void)browsebutton {      browseview = [[uiview alloc]initwithframe:cgrectmake(0.0, 0.0, 300.0, 500.0)];     browseview.backgroundcolor = [uicolor whitecolor];     browseview.opaque = no;     [browseview.layer setbordercolor: [[uicolor blackcolor] cgcolor]];     [browseview.layer setborderwidth: 4.0];     [browseview setbackgroundcolor:[uicolor clearcolor]];     browsetableview = [[uitableview alloc]initwithframe:cgrectmake(0.0, 0.0, 300, 460)];     [browseview addsubview:browsetableview];     [self.view addsubview:browseview];       }  -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     categoryarray =  [[nsmutablearrayalloc]initwithobjects:@"platinum",@"diamond",     @"gold",@"silver", nil];     return [categoryarray count]; }  -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath  {     uitableviewcell *cell = [[uitableviewcell alloc]init];     cell.textlabel.text = [categoryarray objectatindex:indexpath.row];     return cell; }   

you forgot mention:

browsetableview = [[uitableview alloc]initwithframe:cgrectmake(0.0, 0.0, 300, 460)]; browsetableview.delegate = self; browsetableview.datasource = self; [browseview addsubview:browsetableview]; 

Comments