数据绑定UITableView变全屏了,怎么不让它变成全屏!
我的代码如下:
@synthesize myTableView;
NSMutableArray *ds;
- (void)viewDidLoad
{
[super viewDidLoad];
ds=[[NSMutableArray alloc] init];
[ds addObject:@"1"];
[ds addObject:@"2"];
[ds addObject:@"3"];
[ds addObject:@"4"];
[ds addObject:@"5"];
UITableView *tableView =[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
tableView.dataSource= self;
tableView.delegate=self;
self.myTableView =tableView;
[self.view addSubview:myTableView];
}
-(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];
}
NSString *cellValue =[ds objectAtIndex:indexPath.row];
cell.textLabel.text=cellValue;
return cell;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return ds.count;
}
------解决方案--------------------
设置tableView 的frame
------解决方案--------------------
UITableView *tableView =[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
把这个改下就行了,用CGRectMake自己设置