嘿伙计们,我找了这个问题,我不相信我能找到答案.我有自定义单元格的表格视图,单击时,所选单元格会推送包含信息的新单元格.我想知道是否有人知道如何将所选单元格推到uitableview的顶部,或者让它填满整个tableview.
我的uitableview只占用屏幕的一半,我希望当选择单元格时它只占用屏幕的一半,用户仍然可以滚动单元格(如果这有意义)?
任何建议都会受到赞赏,有些难以描述我在寻找什么,所以如果有人需要澄清,请不要犹豫,问我.
谢谢!
我正在做一个需要扩展单元格的应用程序,以显示更多细节.我使用了自定义单元格并将它们添加到UItableview中.当我点击单元格时,它会动画很好并且向下移动,当我再次单击它时,它会上升,这是通过更改单元格的高度来完成的.实际的自定义单元格大小比我通常显示的单元格大.当我点击细胞时,显示整个细胞.我遇到的唯一问题是数据溢出.未选择单元格时,应隐藏这些数据.只有在选择时才应显示这些数据.
我提到了不同的文章,尝试改变颜色设置绑定对我不起作用.我有同样的问题在这个问题iphone uitablecellview溢出问,尝试了答案,但它没有奏效.
我需要的是如何在未扩展时隐藏自定义单元格的底部部分,并在扩展时显示它!...
这些是我的屏幕截图
当它被加载
当我点击一个单元格]
当我点击第二个单元格时

当我点击已经展开的单元格时这些是我用过的代码剪辑....
// Declaring the SearchResultTable.
CGRect filterFrame = CGRectMake(0,31, 320, 400);
self.searchResultTable = [[UITableView alloc] initWithFrame:filterFrame];
self.searchResultTable.dataSource = self;
self.searchResultTable.delegate = self;
self.searchResultTable.backgroundColor = [UIColor whiteColor];
self.searchResultTable.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
self.searchResultTable.separatorColor = [UIColor lightGrayColor];
[self.view addSubview:self.searchResultTable];
//Adding cells
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ExpandedSearchResultTableCell";
ExpandedSearchResultTableCell *cell = (ExpandedSearchResultTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell.contentView.clipsToBounds = YES;
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ExpandedSearchResultTableCell" owner:self …Run Code Online (Sandbox Code Playgroud) 我在Signup控制器上设置了五个字段.用户名,显示名,密码,确认密码和电子邮件地址.
它们设置如下:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.textColor = [UIColor colorWithRed:14.0f/255.0f green:62.0f/255.0f blue:178.0f/255.0f alpha:0.8f];
cell.textLabel.font = [UIFont boldSystemFontOfSize:13.0f];
switch ( indexPath.row ) {
case 0: {
cell.textLabel.text = NSLocalizedString(@"UsernameFieldLabel", @"Username field label");
[cell addSubview:self.usernameField];
break ;
}
case 1: {
cell.textLabel.text = NSLocalizedString(@"DisplayNameFieldLabel", @"Displayname field lael");
[cell addSubview:self.displayNameField];
break ;
}
case 2: {
cell.textLabel.text = NSLocalizedString(@"PasswordFieldLabel", @"Password field …Run Code Online (Sandbox Code Playgroud) 我创建了一个自定义单元格FeatureCell,它在行中有5个图像将在主视图中调用,但是当我调用它时,我得到空行.那么请问哪里可能是我的问题?
我已经搜索了自定义单元格,我使用了我在下面的代码中使用的方式但没有任何反应.
这是我的FeatureCell.h
@interface FeatureCell : UITableViewCell{
IBOutlet UIImageView *img1;
IBOutlet UIImageView *img2;
}
@property (nonatomic, retain) UIImageView *img1;
@property (nonatomic, retain) UIImageView *img2;
@end
Run Code Online (Sandbox Code Playgroud)
这是我的FeatureCell.m
@implementation FeatureCell
@synthesize img,img1,img2,img3,img4;
@end
Run Code Online (Sandbox Code Playgroud)
这是我的视图控制器.m
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section == 0) {
return [objectCollection count];
}
else{
return 1;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier1 = @"FeatureCell";
FeatureCell *cell1 = (FeatureCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
if (cell1 == nil)
{
NSArray …Run Code Online (Sandbox Code Playgroud) 我无法弄清楚为什么没有输出这个自定义单元格.
我在故事板中设置了自定义单元格(没有笔尖).我有一个文本字段和2个标签,当我尝试在自定义单元格类中访问它们时为nil.我几乎可以肯定我已经把所有东西都搞定了,但仍然没有.
我已经在故事板中选择了我的表格单元格并将自定义类设置为TimesheetTableViewCell
我也控制了单击该表并将数据源和委托设置为TimesheetViewController
我的自定义单元类:
import UIKit
class TimesheetTableViewCell: UITableViewCell {
@IBOutlet var duration: UITextField!
@IBOutlet var taskName: UILabel!
@IBOutlet var taskNotes: UILabel!
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override init?(style: UITableViewCellStyle, reuseIdentifier: String!) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
println("Cell's initialised")// I see this
println(reuseIdentifier)// prints TimesheetCell
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
func setCell(duration: String, taskName: String, taskNotes: String){
println("setCell called")
self.duration?.text = duration
self.taskName?.text = taskName
self.taskNotes?.text = …Run Code Online (Sandbox Code Playgroud) 我正在尝试将一个XIB文件用于多种类型的自定义UITableViewCell子类(相同的IBOutlets - 相同的外观 - 不同的方法和逻辑).
我怎样才能做到这一点?
我刚刚开始使用Swift作为一种prorgamming语言,我遇到了自定义单元格的问题.
当我尝试创建自定义单元格,然后前进并尝试按照我需要的方式设计它们(将Style设置为Custom)一切看起来都不错.现在我不知道如何将特定数据放入其中,因为我找到的所有教程都使用了样式选项"basic",它们只有一个文本标签,用于分配数据.
现在对我来说,当我"控制"将我的标签拖到我的代码中时,我会给它们特定的名称,例如"dateLabel"或"sourceLabel",以便正确插入数据.
现在我不确定,也找不到任何有效的答案,如何回忆我的定制标签,以便我可以将数据分配给他们......
也许有人可以帮助我,因为我很确定这是一个简单的问题,但我找不到任何资源给这个^^
希望字体不小,我只是想让你们看到我得到的错误.
我使用以下教程作为指导,因为它是唯一一个按照这个人的方式工作的方法:https://www.youtube.com/watch?v = 0qE8olxB3Kk
我检查了标识符,他设置正确,我无法在网上找到任何关于我如何正确引用我自己的正确名称的标签.
任何帮助,将不胜感激 :)
我有一个问题,我不知道如何解决。
我有两个自定义单元格笔尖 - 两者的数据都是从单独的数组中获取的。
结构如下
nib1-cell line1
nib1-cell line2
...
nib1-cell line n
nib2-cell line1
Run Code Online (Sandbox Code Playgroud)
末尾始终有一个 nib2-cell,后缀为uibutton.
一旦uibutton按下 - nib1 数组就会被附加。
我找到了一种如何在 底部插入值的方法tableview,但是当我向下或向上滚动时,带有 nib2 的单元格将被重用并替换为 nib1 单元格数据。

我怎样才能防止这些单元被重复使用或保存它们的状态?
谢谢。
更新:数据源和 cellForRowAtIndexPath 代码
func tableView(tableView: UITableView, numberOfRowsInSection 部分: Int) -> Int {
return someTagsArray.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if(indexPath.row < someTagsArray.count - 1){
var cell:TblCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! TblCell
cell.lblCarName.text = someTagsArray[indexPath.row]
return cell
} else if (indexPath.row == …Run Code Online (Sandbox Code Playgroud) 我有一个带有自定义单元格的tableView。每个单元都有不同的界面、元素。它们都有不同的尺寸。每个单元格都有不同类型的元素及其数量。所有这些元素都是动态创建的,因此我正在创建它们,制作它们的框架并添加为子视图。
因此, heightForRowAtIndexPath在cellForRowAtIndexPath之前执行的问题是,我正在创建行并构造其接口,但我不知道如何将计算出的高度传递给heightForRowAtIndexPath
如何计算之前的行高并将其值传递给 heightForRowIndexPath以正确绘制我的 tableView?
我在这里遇到了非常奇怪的问题。
基本上,用户会看到一个附加了 TableView 的视图。调用后端获取一些数据,并在完成块中将该数据提供给 TableView 进行显示。
在 cellForRow 1 of 4 可重用的自定义单元中,根据某种逻辑将自定义单元出队,然后调用该单元的配置方法。
这就是它变得棘手的地方:一些单元格可能需要进一步的异步调用(以获取更多数据用于其自定义显示),因此需要 tableView.reloadRows 调用......那么,发生的事情最好通过这两个屏幕截图来解释:
第一个单元格中写着“有没有想过你会为克朗代克酒吧做什么?” 被复制到“演员的自我管理”单元格的顶部,作为包含 Twitter 信息的单元格,该单元格确实需要额外的异步调用来获取该数据。
有什么想法吗?我正在 begin/endUpdates 块内运行 tableView.reloadRows 调用,但没有骰子。
行单元格:
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let postAtIndexPath = posts[indexPath.row]
let cell: PostCell!
if postAtIndexPath.rawURL == "twitter.com" {
cell = tableView.dequeueReusableCell(withIdentifier: "TwitterCell", for: indexPath) as! TwitterCell
} else if !postAtIndexPath.rawURL.isEmpty {
cell = tableView.dequeueReusableCell(withIdentifier: "LinkPreviewCell", for: indexPath) as! LinkPreviewCell
} else if postAtIndexPath.quotedID > -1 {
cell = tableView.dequeueReusableCell(withIdentifier: "QuoteCell", …Run Code Online (Sandbox Code Playgroud) custom-cell ×10
ios ×9
uitableview ×7
swift ×5
iphone ×3
objective-c ×2
height ×1
ios-4.2 ×1
ios5 ×1
tableview ×1
uibutton ×1
xib ×1