让IO7下的table cell从最左边开始

本文介绍了解决iOS7中UITableView的cell分隔线未从最左侧开始的问题。通过检查系统版本并调整TableView的separatorInset属性,可以确保在iOS7及更高版本上分隔线与iOS6保持一致的显示效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

IOS7,发现使用uitableview时,cell的分隔线并不是从最左边开始的。

如图:


这个体验和IOS6下不一致,原因是IOS7下的主要内容默认起始位置不为0.

用如下代码解决:

//判断版本宏定义
#define NLSystemVersionGreaterOrEqualThan(version) ([[[UIDevice currentDevice] systemVersion] floatValue] >= version)
#define IOS7_OR_LATER NLSystemVersionGreaterOrEqualThan(7.0)


//适配IOS7,IO7下table cell默认不是从最左边开始
if (IOS7_OR_LATER) {
    [self.ableView setSeparatorInset:UIEdgeInsetsZero];
}

修复后,可以看到分隔线是从头开始,和IOS体验一致。

### Golang Fyne Framework Table Component Usage Example In the context of using tables within the Fyne framework for developing graphical user interfaces with Go (Golang), a table is an essential widget that allows displaying data in rows and columns format. Below demonstrates how to create and customize a `Table` component. To utilize the `Table` widget effectively, one must define its structure through implementing specific methods required by the interface such as creating cell widgets or determining content based on row and column indices[^1]. #### Basic Implementation of a Table Widget Using Fyne ```go package main import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" ) func main() { myApp := app.New() window := myApp.NewWindow("Fyne Table Demo") tableData := [][]string{ {"John", "Doe"}, {"Jane", "Smith"}, } tableWidget := widget.NewTable( func() (int, int) { return len(tableData), 2 }, // Number of rows and columns. func(id fyne.CanvasObjectID, cell *widget.TableCell) { row, col := id.Row, id.Col cell.Text = tableData[row][col] }, func() fyne.CanvasObject { return widget.NewLabel("") }) window.SetContent(container.NewVBox( widget.NewLabel("Simple Table"), tableWidget, )) window.Resize(fyne.NewSize(300, 400)) window.ShowAndRun() } ``` This code snippet initializes a simple application window containing a basic table populated with static string values arranged into two columns representing first names and last names respectively. The function provided when calling `NewTable()` specifies the number of rows and columns along with logic for populating each cell's text property dynamically according to position within the dataset.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值