当前位置: 代码迷 >> Iphone >> 数据绑定UITableView变全屏了,如何不让它变成全屏
  详细解决方案

数据绑定UITableView变全屏了,如何不让它变成全屏

热度:81   发布时间:2016-04-25 05:53:35.0
数据绑定UITableView变全屏了,怎么不让它变成全屏
数据绑定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自己设置
  相关解决方案