#import "ViewController.h"
@interface Viewcontroller ()
{
UITableView *_table;
Nsmutablearray *_datalist;
UIView *footview;
}
@end
@implementation Viewcontroller
-(void) viewdidload
{
[Super Viewdidload];
_table=[[uitableview alloc]initwithframe:cgrectmake (0, 0, self.view.frame.size.width, self.view.frame.size.height) ];
_table.delegate=self;
_table.datasource=self;
_table.multipletouchenabled=yes;
[Self.view addsubview:_table];
_datalist=[[nsmutablearray alloc]initwithobjects:@ "1111n111n111n111n", @ "222", @ "333", @ "444", @ "555", @ "666", @ "777" , nil];
Footview=[[uiview alloc]initwithframe:cgrectmake (0, 0, 320, 80)];
Footview.backgroundcolor=[uicolor Yellowcolor];
_table.tablefooterview=footview;
}
-(void) didreceivememorywarning
{
[Super didreceivememorywarning];
Dispose of any of the can is recreated.
}
#pragma mark-uitableview
-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView
{
return 1;
}
-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section
{
return [_datalist Count];
}
-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) IndexPath {
static NSString *cellidentifier = @ "Cell";
UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:cellidentifier];
if (cell = = nil) {
cell = [[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier];
Uilabel *label = [[Uilabel alloc] Initwithframe:cgrectzero];
Label.tag = 1;
//label.linebreakmode = uilinebreakmodecharacterwrap;
Label.linebreakmode=nslinebreakbycharwrapping;
Label.highlightedtextcolor = [Uicolor Whitecolor];
Label.numberoflines = 0;
Label.opaque = no;//select opaque to indicate that nothing behind the view should be drawn
Label.backgroundcolor = [Uicolor clearcolor];
[Cell.contentview Addsubview:label];
}
Uilabel *label = (Uilabel *) [cell viewwithtag:1];
NSString *text;
Text = [_datalist ObjectAtIndex:indexPath.row];
CGRect cellframe = [cell frame];
CELlframe.origin = cgpointmake (0, 0);
Label.text = text;
CGRect rect = Cgrectinset (Cellframe, 2, 2);
Label.frame = rect;
[Label SizeToFit];
if (Label.frame.size.height > m) {
CellFrame.size.height = + label.frame.size.height-46;
}
Else {
CellFrame.size.height =;
}
[Cell setframe:cellframe];
return cell;
}
-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) Indexpath
{
UITableViewCell *cell = [self Tableview:tableview cellforrowatindexpath:indexpath];
return cell.frame.size.height;
}
@end