Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ios iphone删除按钮(滑动以删除)会弄乱uitablecellview内容_Ios_Xcode_Uitableview_Swipe - Fatal编程技术网

ios iphone删除按钮(滑动以删除)会弄乱uitablecellview内容

ios iphone删除按钮(滑动以删除)会弄乱uitablecellview内容,ios,xcode,uitableview,swipe,Ios,Xcode,Uitableview,Swipe,我的UITableCellView有问题。当“删除”按钮出现时,它会弄乱我的表格行 例如: ------------------- blah blah blah blah ------------------- line 2 ------------------- so on... ------------------- 。。。在我尝试在第1行刷删除后 -------------------- blah blah [delete] blah --------------- blah 2

我的
UITableCellView
有问题。当“删除”按钮出现时,它会弄乱我的表格行

例如:

-------------------
blah blah blah blah
-------------------
line 2
-------------------
so on...
-------------------
。。。在我尝试在第1行刷删除后

--------------------
blah blah   [delete]
blah ---------------
blah  2
--------------------
so on...
--------------------
我不知道如何解决这个问题

当“删除”按钮出现时,是否仍然可以使
UITableCellView
不收缩

为了澄清,我用一个覆盖的
layoutSubviews
UITableCellView
进行了子类化,但方式非常简单。我只是把我的标签和计算的大小和东西,非常基本


如果您在mail应用程序或facebook应用程序上尝试相同的操作,则“删除”按钮只会覆盖表格单元格行的内容。如何操作?

您需要为标签设置
lineBreakMode

label.lineBreakMode = UILineBreakModeTailTruncation;

如果不希望在编辑模式下缩小单元格的子视图,请尝试将单元格的子视图的
自动调整大小任务设置为:

_messageLabel.autoresizingMask = UIViewAutoresizingNone;

你必须使用

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
    [super setEditing:editing animated:animated];

    if (editing) {
        // EDITING state

        // You can describe animations here

     } else {
        // NORMAL state
     }

}

方法来描述更改,在您的
UITableViewCell
子类中不确定这是否有帮助,因为这个问题已经很老了。然而,我的表格单元格中有3个UI元素,它们在刷卡时没有得到正确处理

我花了一段时间才终于明白,在我将“换行符”改为“剪辑”后,一切都正常工作了


哦,如果你有一个文本字段/标签可以自动调整大小,那么在滑动操作期间,它也会弄乱布局

那么,你是说如果UITableViewCell contentView正在编辑,我应该重置它的宽度吗?@Rebecca Alison是的,那应该试试。奇怪的是,默认情况下,内容视图应该向右移动,而布局没有改变。所以我猜,您的layoutSubviews方法存在问题。我通常不使用它,因为它会变得相当复杂。使用三种方法可以获得相同的结果:setHighlighted、setSelected和setEditing。也许你可以重新排列你的代码,然后在每个方法中描述你希望单元格看起来是什么样子,也许是在一个动画块中。我找到了一种实现我想要的方法,-(void)layoutSubviews{[super layoutSubviews];CGRect contentRect=self.contentView.bounds;if(UIInterfaceOrientationIsLandscape([UIDevice currentDevice.orientation]{contentRect.size.width=480.0f;}其他{contentRect.size.width=320.0f;}我不喜欢将常量值设置为宽度,但上面的设置很有效。我需要找到比使用常量值更好的方法。如果未来的iphone更改分辨率,我的应用程序会很糟糕!我尝试了,但没有成功。我的标签如下所示[u messageLabel=[[UILabel alloc]init]messageLabel.backgroundColor=kDefaultBackgroundColor;messageLabel.textColor=kTextColor;messageLabel.textAlignment=UITextAlignmentLeft;messageLabel.font=[UIFont systemFontOfSize:17]messageLabel.numberOfLines=0;messageLabel.lineBreakMode=UILineBreakModeTailTruncation;messageLabel.autoresizingMask=UIViewAutoresizingFlexibleHeight;所以您打算将其作为多行标签?这不起作用,但我找到了一种解决问题的方法。请参阅我上面的评论。。。