本文介绍了UITableviewCell的自定义尺寸删除按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用此代码调整 UITableView
单元格的删除按钮的大小,但由于某些原因,x&y工作正常,但我无法更改高度&;删除按钮的宽度.我在自定义的 UITableViewCell
类中使用了此代码,并且在宽度&删除"按钮的高度.我在这里想念什么?
I'm trying to resize UITableView
cell's delete button with this code but for some reason, the x & y are working fine but i'm unable to change the height & width of the delete button. I'm using this code in my custom UITableViewCell
class and everything works fine excel the width & hight of the "Delete" button.what am i missing here?
- (void)layoutSubviews
{
[super layoutSubviews];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.0f];
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
CGRect newFrame = subview.frame;
newFrame.origin.x = 250;
newFrame.origin.y = 47;
newFrame.size.height = 30;
newFrame.size.width = 50;
deleteButtonView.frame = newFrame;
subview.frame = newFrame;
}
}
[UIView commitAnimations];}
推荐答案
使用此代码...
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
UIView *deleteButtonView = (UIView *)[subview.subviews objectAtIndex:0];
CGRect f = deleteButtonView.frame;
f.origin.x = 250;
f.origin.y = 47;
f.size.width = 30;
f.size.height = 50;
CGRect sf = self.frame;
sf.size.width = 100;
sf.size.height = 100;
deleteButtonView.frame = f;
self.frame = sf;
}
从此链接中查看另一个答案... iphone-uitableview-delete-button
see another answer from this link...iphone-uitableview-delete-button
这篇关于UITableviewCell的自定义尺寸删除按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!