小编Swa*_*nil的帖子

从Xcode代码覆盖率报告中排除文件

有没有办法在XCode代码覆盖范围内排除文件.

我做了研究,发现了一些工具 - 在Xcode 7代码覆盖范围中排除文件/代码行

但所有这些都是第三方工具.我们有什么方法可以在xcode中自己做到吗?

xcode code-coverage ios

16
推荐指数
1
解决办法
1519
查看次数

UICollectionView单元格消失

我在我的iPad应用程序中使用collectionView.我使用了继承UICollectionViewFlowLayout类的自定义布局类.

我正在使用水平滚动方向.问题是,每当我们使用滚动进行集合视图时,有时候单元格会消失.我调试了代码,发现在创建单元格后的数据源方法中,其隐藏属性自动获得ON.

我尝试使用下面的线,但它无法正常工作

   cell.hidden = NO  
Run Code Online (Sandbox Code Playgroud)

我在下面的方法也使绑定更改的布局无效.

    - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
          return YES;
        }
Run Code Online (Sandbox Code Playgroud)

但我仍面临着问题.对此有何解决方案?

提前致谢.

objective-c ios uicollectionview uicollectionviewcell

11
推荐指数
1
解决办法
6931
查看次数

在XCode中导出文件中的所有警告

我编写了显示Xcode警告的脚本.例如TODO警告.该脚本将在每个XCode版本上运行.(我在"运行阶段"选项中编写了脚本).

现在我想收集并将所有这些警告导出到文本文件.有没有办法将所有警告或构建错误导出到文本文件?

shell xcode objective-c ios

10
推荐指数
1
解决办法
1478
查看次数

如何获取iPhone资源文件夹中的文件夹和文件列表?

我在我的资源文件夹中做文件夹结构,比如... Resource => MyData => S1然后在S1 => Name.png,data.ppt

现在我想获取所有文件夹列表和文件名.这里MyData名称只是静态其他可能会改变.就像我可以添加S1,S2,S3和那里的文件数量.那么如何通过Objective C阅读这些内容呢?我试过下面的代码.

NSString *bundlePathName = [[NSBundle mainBundle] bundlePath];
    NSString *dataPathName = [bundlePathName stringByAppendingPathComponent:@"Resources"];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if ([fileManager fileExistsAtPath:dataPathName]) {
        NSLog(@"%@ exists", dataPathName);
        BOOL isDir = NO;
        [fileManager fileExistsAtPath:dataPathName isDirectory:(&isDir)];
        if (isDir == YES) {
            NSLog(@"%@ is a directory", dataPathName);
            NSArray *contents;
            contents = [fileManager contentsOfDirectoryAtPath:dataPathName error:nil];
            for (NSString *entity in contents) {
                NSLog(@"%@ is within", entity);
            }
        } else {
            NSLog(@"%@ is not a directory", dataPathName);
        }
    } else …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ipad ios

8
推荐指数
1
解决办法
2万
查看次数

UICollectionView列网格间隙

UICollectionView在我的iPad应用程序中使用流布局.我有不同宽度和高度的细胞.当我使用UICollectionViewFlowLayout作为集合视图的布局的子类时,它显示了单元格之间的间隙.

如果列中有大单元格,则会使该列的网格和小单元格呈现为列中的大单元格的居中.有没有更好的方法来紧密细胞包裹?

我正在使用水平滚动.我尝试使用layoutAttributesForElementsInRect:方法,但没有成功.

如果有人通过使用layoutAttributesForElementsInRect:方法或其他方式做同样的事情,请告诉我...

请找附件.我需要同样的解决方案在此输入图像描述

提前致谢...

objective-c ios uicollectionview

7
推荐指数
1
解决办法
1518
查看次数

iPhone应用程序中的谷歌地图导航和方向

我想在我的iPhone应用程序中使用谷歌地图导航和方向功能.我应该参考哪些样本应用程序或文档?这是付费功能吗?

谢谢,

iphone google-maps objective-c

6
推荐指数
1
解决办法
3876
查看次数

如何避免iOS设备图库中的图像重复?

我想将图像存储到照片中.但是如果图像已经可以在照片中获得,那么如何区分imga是否已经存在?我没有找到像唯一标识符的属性,或者我应该通过采用NSdata形式的数据进行比较?

谢谢..

iphone objective-c

6
推荐指数
1
解决办法
166
查看次数

Swift扩展 - 方法与先前使用相同Objective-C选择器的声明冲突

我正在开发iOS应用程序,它有Obj C代码以及Swift.我正在将现有的Objective C类别迁移到swift代码.但是当我在swift扩展中覆盖现有方法时,它没有编译.Swift扩展适用于新方法,但不适用于覆盖现有方法.

码:

extension UIViewController {


   public override func shouldAutorotate() -> Bool {
        return false
    }

    public override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.Portrait
    }


}
Run Code Online (Sandbox Code Playgroud)

错误:

 Method 'shouldAutorotate()' with Objective-C selector 'shouldAutorotate' conflicts with previous declaration with the same Objective-C selector

 Method does not override any method from its superclass

 Method 'supportedInterfaceOrientations()' with Objective-C selector 'supportedInterfaceOrientations' conflicts with previous declaration with the same Objective-C selector
Run Code Online (Sandbox Code Playgroud)

在这里,我错过了什么?

我正在使用Xcode 7.3.1Swift 2.x

编辑:

从Answers下面,我知道我们不能像在Objective C Categories中那样在Swift扩展中改变运行时类的现有方法的行为.在这里,我应该创建一个将覆盖方法的基类,我应该使用我的所有ViewControllers作为新基类的子类作为父类.

但就我而言,我想改变所有"shouldAutorotate"方法的行为,包括第三方框架UIViewController.在上面的例子中,我不能强制所有第三方框架UIviewControllers成为我的基类的子类.在Objective …

objective-c ios swift swift2

5
推荐指数
1
解决办法
3497
查看次数

MkMapView缩放级别

我使用MkMapView与谷歌地图.我成功显示地图视图和地址与注释pin.But我想要增加缩放级别.如何以编程方式设置它????

-(void)showMyAddress
{

//Hide the keypad
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.2;
span.longitudeDelta=0.2;

CLLocationCoordinate2D location = [self addressLocation];
region.span=span;
region.center=location;



if(addAnnotation != nil) {
    [mapView removeAnnotation:addAnnotation];
    [addAnnotation release];
    addAnnotation = nil;
}


addAnnotation = [[AddAnnotation alloc] initWithCoordinate:location ];
[addAnnotation setMTitle:@"abc"];
[addAnnotation setMSubTitle:@"def."]




[mapView addAnnotation:addAnnotation];

[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];


}


-(CLLocationCoordinate2D) addressLocation {
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", 
                       [@"abc" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];


NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSStringEncodingConversionAllowLossy  error:nil];
NSArray *listItems = [locationString componentsSeparatedByString:@","];

double latitude = 0.0;
double longitude = 0.0; …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c mkmapview ios

4
推荐指数
1
解决办法
2万
查看次数

typedef结构的内存泄漏

我试图消除内存泄漏.以下是我的代码.

currentTime = CFAbsoluteTimeGetCurrent();

CFTimeZoneRef currentTimeZone = CFTimeZoneCopyDefault();

todaysDate = CFAbsoluteTimeGetGregorianDate(currentTime, currentTimeZone);


[currentTimeZone release];
currentTimeZone = nil;
Run Code Online (Sandbox Code Playgroud)

警告::/ myclass.m:87:警告:无效的接收器类型'CFTimeZoneRef'

如何释放typedef const struct的内存?

iphone memory-leaks objective-c

4
推荐指数
1
解决办法
452
查看次数