Uitableview e可疑代码。对新的细节有什么见解吗?我替换了以下代码:UIView*view=[[UIView alloc]initWithFrame:self.frame];view.backgroundColor=[UIColor colorWithPatternIm
Uitableview e可疑代码。对新的细节有什么见解吗?我替换了以下代码:UIView*view=[[UIView alloc]initWithFrame:self.frame];view.backgroundColor=[UIColor colorWithPatternIm,uitableview,ios7,xcode5,Uitableview,Ios7,Xcode5,e可疑代码。对新的细节有什么见解吗?我替换了以下代码:UIView*view=[[UIView alloc]initWithFrame:self.frame];view.backgroundColor=[UIColor colorWithPatternImage:[UIImage ImageName:@“cell_background_normal.png”];self.backgroundView=视图;使用以下代码:[self-setBackgroundColor:[uicolorWithP
e可疑代码。对新的细节有什么见解吗?我替换了以下代码:UIView*view=[[UIView alloc]initWithFrame:self.frame];view.backgroundColor=[UIColor colorWithPatternImage:[UIImage ImageName:@“cell_background_normal.png”];self.backgroundView=视图;使用以下代码:[self-setBackgroundColor:[uicolorWithPatternImage:[UIImage imageNamed:@“cell_background_normal.png”]];在定制我的自定义单元格时,我仍然不确定如何在代码中使用它,因为我有一个需要添加的CAGradientLayer。不管怎样,我已经放弃了渐变,因为当我删除它时,删除按钮是可见的,单元格的纯白色外观与iOS7的设计模式相匹配。谢谢你的帮助!很好的解决方案。这是防止重新覆盖删除按钮的方法。在iOS6中,我曾将左侧的删除控件从(-)更改为(I),但现在行会滑动。有没有一种简单的方法可以在iOS7中保留iO6的方式,或者我只需要接受我的行的一部分在滑动时会被隐藏。你能简单地解释一下吗。如何在自定义单元格和默认单元格中对背景视图进行子类化。不幸的是,对于自定义格式的单元格,这使单元格上的文本不可见-在这篇描述修复的文章中可以看到正在发生的事情:我尝试了这个,我知道代码正在运行,但是我的删除按钮仍然在消失。
- (void) setupGradientsWithHeight:(int) the_height
{
CAGradientLayer* gradient = [CAGradientLayer layer];
gradient.frame = CGRectMake(self.bounds.origin.x,
self.bounds.origin.y,
self.bounds.size.width,
the_height);
gradient.colors = [NSArray arrayWithObjects:
(id)[UIColor colorWithRed:218.0f/255.0f
green:218.0f/255.0f
blue:220.0f/255.0f
alpha:1.0].CGColor,
(id)[UIColor colorWithRed:180.0f/255.0f
green:180.0f/255.0f
blue:184.0f/255.0f
alpha:1.0].CGColor,nil];
UIView* bgview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
[bgview.layer addSublayer:gradient];
[self setBackgroundView:bgview];
}
- (void)setFrame:(CGRect)frame
{
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) {
// background view covers delete button on iOS 7 !?!
[super setFrame:CGRectMake(0, frame.origin.y, frame.size.width, frame.size.height)];
} else {
[super setFrame:frame];
}
}
+ (Class)layerClass
{
return [CAGradientLayer class];
}
-(void)didTransitionToState:(UITableViewCellStateMask)state
{
if (state & UITableViewCellStateShowingDeleteConfirmationMask ) {
[self sendSubviewToBack:self.contentView];
}
[super didTransitionToState:state];
}
cell.layer.contents = (id)[UIImage imageNamed:@"singleRow.png"].CGImage;
- (void)layoutSubviews
{
[super layoutSubviews];
for (UIView *subview in self.subviews) {
for (UIView *subview2 in subview.subviews) {
if ([NSStringFromClass([subview2 class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"]) { // move delete confirmation view
[subview bringSubviewToFront:subview2];
}
}
}
- (void)layoutSubviews
{
[super layoutSubviews];
[self sendSubviewToBack:self.contentView];
}
[myTableView setEditing:NO animated:NO];
[myTableView setEditing:YES animated:NO];
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 && changeTitle) {
return @" Delete";
}
return @"Delete";
}
- (void) layoutSubviews {
[super layoutSubviews];
if ([ [ [UIDevice currentDevice] systemVersion] compare: @"7.0" options: NSNumericSearch] != NSOrderedAscending) {
if (iOS7 == YES) {
self.backgroundView.frame = CGRectMake(0, self.backgroundView.frame.origin.y,
self.backgroundView.frame.size.width, self.backgroundView.frame.size.height);
}
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
CGRect frame = self.tableView.frame;
if(editing){
[self.tableView setFrame:CGRectMake(0, frame.origin.y, frame.size.width, frame.size.height)];
//other codes to run if needed
}else{
[self.tableView setFrame:frame];
//other codes to run if needed
}