简体   繁体   English

TableView 单元格框架问题

[英]TableView cell frame problem

I am developing an application that has a view as shown in image.我正在开发一个具有如图所示视图的应用程序。 I am having a table view.我有一个表格视图。 My problem is how will I show my chat boxes cell some right to the original Table viewcell frame.我的问题是如何将我的聊天框单元格显示在原始表格视单元框架的右侧。

Like The white box is some right to the original table view cell像白框是原始表格视图单元格的某些权利

code:-代码:-

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";
    int row = [indexPath section];

    UITableViewCell *startCell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(10, 0, 200, 50)  reuseIdentifier:CellIdentifier] autorelease];
    UITableViewCell *durationCell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(50, 0, 200, 100) reuseIdentifier:CellIdentifier] autorelease];
    UITableViewCell *radiusCell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(100, 0, 200, 150) reuseIdentifier:CellIdentifier] autorelease];

    startCell.textLabel.text = @"Start:";
    durationCell.textLabel.text = @"Duration:";
    radiusCell.textLabel.text = @"radius";


    if (row == 0)
    {
        return startCell;
    }
    else if (row == 1)
    {
        return durationCell;
    }

    return radiusCell;


}

You need to set frame of the view which is inside cell in cellForRowAtIndexPath method or you can make custom cell and position it where ever you want.您需要在 cellForRowAtIndexPath 方法中设置单元格内的视图框架,或者您可以在任何地方制作自定义单元格和 position。

if your cell contains UIImageView then you have to create custom cells.如果您的单元格包含 UIImageView 那么您必须创建自定义单元格。 In custom cell 'sm file you have to create a method called - (void)layoutSubviews in that method write code for image view like在自定义单元格的 sm 文件中,您必须在该方法中创建一个名为- (void)layoutSubviews的方法,为图像视图编写代码,例如

   `CGRectMake frame= CGRectMake(5, 12, 19, 15);    
    myImageView.frame = frame;`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM