简体   繁体   English

我如何在TableViewCell中实现

[英]how do i achieve this in TableViewCell

see below figure, it has- TableView & tablecell have same background image ietableview & tablecell must not look different. 参见下图,它具有-TableView和tablecell具有相同的背景图像,即tableview和tablecell的外观必须相同。 in tableCell there must be one button . 在tableCell中必须有一个按钮。
在此处输入图片说明

To achieve this you'll have to create a customized UITableViewCell. 为此,您必须创建一个自定义的UITableViewCell。

  1. You'll required 4 background image for your cell. 您需要为单元格提供4张背景图片。

    a. 一种。 Image Facing right. 图像朝右。 b. b。 Rollover image facing right. 翻转图像朝右。 c. C。 Image Facing left. 图像朝左。 d. d。 Rollover image facing left. 翻转图像朝左。

You'll have to set alternate image to your cell. 您必须为您的单元格设置备用图片。 And when you click on the cell you'll need to change the background image of that particular cell to Rollover image. 当您单击该单元格时,需要将该特定单元格的背景图像更改为“翻转图像”。 Also you'll have to manage the frames of your rest of the control accordingly. 另外,您还必须相应地管理其余控件的框架。

This is nothing but the image. 这不过是图像。 You have to set an image in every tableviewcell by passing the condition 您必须通过传递条件在每个tableviewcell中设置图像

if(indexpath.row/2 == 0)
    <set_image1>
else
   <set_image2>

then adjust other parameters according to your desired frame position. 然后根据所需的帧位置调整其他参数。

Note: You need to use dynamic tableviewcell height & You need for images for this.Two when cell is not selected & rest two when cell got selected 注意:您需要使用动态tableviewcell高度&为此需要图像。未选择单元格时两个,选择单元格时休息两个

Enjoy Programming! 享受编程!

I did this following way: I created two prototype cells having different Cell identifier eg left cell identifier= Cell1 & right cell identifier=Cell2. 我按照以下方式进行操作:我创建了两个具有不同单元标识符的原型单元,例如,左单元标识符= Cell1,右单元标识符= Cell2。

simply put one round-rect button, make it as custom because it shows only in image shape made table cell background color as clearColor, it requires because for the feel of table cell & tableview must look same. 只需放置一个圆角矩形按钮,使其自定义即可,因为它仅以图像形状显示,使表格单元格背景色为clearColor,这需要这样做,因为表格单元格和tableview的外观必须相同。

also set tableView background color as clearColor & add images to both button. 还将tableView的背景色设置为clearColor并将图像添加到两个按钮。

if ((indexPath.row)%2!=0)
    {
        CellIdentifier=@"Cell1";
    }
    else
    {
        CellIdentifier=@"Cell2";

    }

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    UIButton *topicButton=(UIButton *)[cell viewWithTag:1];

    NSString *topicNameLabel=[_topics objectAtIndex:indexPath.row];

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

相关问题 我在其他TableView中使用过TableViewCell。 那么如何将TableViewCell的选定按钮的值提取到TableView - I have used TableViewCell in Different TableView. So how do I fetch TableViewCell's selected button's value to TableView 如何在iPhone的DIV上达到100%[窗口]高度? - How do I achieve 100% [window] height on DIV on iPhone? 如何填充TableViewCell LeftDetail? - How can I populate a TableViewCell LeftDetail? 我怎么能禁止选择一个tableviewcell - how could i forbid a tableviewcell to be selected 如何根据webview高度修复tableviewcell的高度? (我在每个tableviewcell中加载webview) - How to fix the height of tableviewcell based on webview height? (i am loading webview in each tableviewcell) 如何在自定义的tableViewCell中获取UIButton的indexPath? - How can I get the indexPath of UIButton in a customized tableViewCell? 我如何在TableViewCell中使用不同的字体制作不同的单词 - How can i make different words in a tableviewcell with different font 如何将radioButtons添加到tableviewCell? - How to to add radioButtons into tableviewCell? 如何在Tableviewcell中更新UIProgressview? - How to update UIProgressview in Tableviewcell? 如何在使用单步旋转时实现平滑动画/如何在旋转开始时获得新的帧大小? - How to achieve smooth animation when using single-step rotation / How do I get the new frame size at the start of rotation?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM