如何在 ios 7 上更改重新排序控制图像

Posted

技术标签:

【中文标题】如何在 ios 7 上更改重新排序控制图像【英文标题】:How to change Reorder Control image on ios 7 【发布时间】:2013-09-20 06:16:41 【问题描述】:

我正在寻找一种方法来更改重新排序控件的图像和大小。

我已使用此代码更改重新排序图像:

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

    for (UIControl *control in cell.subviews)
    
        if ([control isMemberOfClass:NSClassFromString(@"UITableViewCellReorderControl")] && [control.subviews count] > 0)
        
            for (UIControl *someObj in control.subviews)
            
                if ([someObj isMemberOfClass:[UIImageView class]])
                
                    UIImage *img = [UIImage imageNamed:@"btn_move.png"];
                    ((UIImageView*)someObj).frame = CGRectMake(0, 0, 30, 24);
                    ((UIImageView*)someObj).image = img;
                
            
        
    
 

此代码在 ios 6 上完美运行,但不适用于 iOS 7。

我该如何解决这个问题?还有其他方法可以更改重新排序控制图像吗?

【问题讨论】:

签入界面构建器,行原型 - 那里应该有选择不同图标的选项 isKindofClss 而不是isMemberOfClass 仍然,没有任何效果:( 您使用的配件的名称是什么?我正在考虑修改 UITableViewAccessoryType:developer.apple.com/library/ios/documentation/UIKit/Reference/… 【参考方案1】:

试试

for(UIView* view in self.table.subviews)
        
            if([[[view class] description] isEqualToString:@"UITableViewWrapperView"])
            
                for(UIView* viewTwo in view.subviews) 
                    if([[[viewTwo class] description] isEqualToString:@"UITableViewCell"]) 
                        for(UIView* viewThree in viewTwo.subviews) 
                            if([[[viewThree class] description] isEqualToString:@"UITableViewCellScrollView"]) 
                                for(UIView* viewFour in viewThree.subviews) 
                                    if([[[viewFour class] description] isEqualToString:@"UITableViewCellReorderControl"]) 
                                        for(UIImageView* viewFive in viewFour.subviews) 
                                            // your stuff here
                                        

                                    
                                
                            
                        
                    
                
            
        

【讨论】:

有没有人试过把这个方法通过 App Store 提交?

以上是关于如何在 ios 7 上更改重新排序控制图像的主要内容,如果未能解决你的问题,请参考以下文章