我正在尝试更新外部单元格中的标签
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
Run Code Online (Sandbox Code Playgroud)
通过使用
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! Cell
Run Code Online (Sandbox Code Playgroud)
在另一个功能.但是,我一直在收到错误.因此,我试图通过使用来引用单元格let cell = Cell()
,但是我得到了错误unexpectedly found nil
.最后,我试过了
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! Cell
Run Code Online (Sandbox Code Playgroud)
但不会返回错误,但标签cell.time.text
不会更新.
我的UITableView的单元格是分组文本字段.当我在模拟器上运行我的代码时,我得到了这个:
如您所见,文本字段周围有灰色区域,而UITableView和按钮的背景为白色.是否可以删除或隐藏分组单元格周围的灰色边框(不是分隔符或框架,而是区域)?如果是这样,我该怎么做?
更新:背景颜色适用于iPhone但不适用于iPad.我在iPad上工作.
我解决了这个问题.解:
UIView *clearView = [[UIView alloc] initWithFrame:[myTableView bounds]];
clearView.backgroundColor = [UIColor clearColor];
myTableView.backgroundView = clearView;
[clearView release];
Run Code Online (Sandbox Code Playgroud)
由于在xib文件上设置背景不起作用,我以编程方式进行了编写.这里myTableView
是xib上的tableView对象.如您所见,我将背景视图替换为具有清晰颜色(透明)的视图.达到了预期的效果.
我想在我的视图中添加无边框UIButton.使用界面构建器,我通过从对象库中拖动Round Rect Button来完成此操作.然后,在属性检查器上,将"类型"更改为"自定义",并将标题保留为"按钮".界面构建器一切正常.但是,程序化方法并非如此.以编程方式,我就是这样做的:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(x, y, width, height)];
[button setTitle:@"Button" forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,不显示该按钮.也许我在这里遗漏了一些东西但是当我将类型更改UIButtonTypeRoundRect
为按钮时会显示.但是,我再次希望按钮无边框.
无论如何,我总是可以使用界面构建器.但是,我想了解为什么程序化方法不起作用.那么,有谁知道问题是什么?