我在我的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)
但我仍面临着问题.对此有何解决方案?
提前致谢.
我编写了显示Xcode警告的脚本.例如TODO警告.该脚本将在每个XCode版本上运行.(我在"运行阶段"选项中编写了脚本).
现在我想收集并将所有这些警告导出到文本文件.有没有办法将所有警告或构建错误导出到文本文件?
我在我的资源文件夹中做文件夹结构,比如... 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) 我UICollectionView在我的iPad应用程序中使用流布局.我有不同宽度和高度的细胞.当我使用UICollectionViewFlowLayout作为集合视图的布局的子类时,它显示了单元格之间的间隙.
如果列中有大单元格,则会使该列的网格和小单元格呈现为列中的大单元格的居中.有没有更好的方法来紧密细胞包裹?
我正在使用水平滚动.我尝试使用layoutAttributesForElementsInRect:方法,但没有成功.
如果有人通过使用layoutAttributesForElementsInRect:方法或其他方式做同样的事情,请告诉我...
请找附件.我需要同样的解决方案
提前致谢...
我想在我的iPhone应用程序中使用谷歌地图导航和方向功能.我应该参考哪些样本应用程序或文档?这是付费功能吗?
谢谢,
我想将图像存储到照片中.但是如果图像已经可以在照片中获得,那么如何区分imga是否已经存在?我没有找到像唯一标识符的属性,或者我应该通过采用NSdata形式的数据进行比较?
谢谢..
我正在开发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.1和Swift 2.x
编辑:
从Answers下面,我知道我们不能像在Objective C Categories中那样在Swift扩展中改变运行时类的现有方法的行为.在这里,我应该创建一个将覆盖方法的基类,我应该使用我的所有ViewControllers作为新基类的子类作为父类.
但就我而言,我想改变所有"shouldAutorotate"方法的行为,包括第三方框架UIViewController.在上面的例子中,我不能强制所有第三方框架UIviewControllers成为我的基类的子类.在Objective …
我使用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) 我试图消除内存泄漏.以下是我的代码.
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的内存?
objective-c ×9
ios ×7
iphone ×5
xcode ×2
google-maps ×1
ipad ×1
memory-leaks ×1
mkmapview ×1
shell ×1
swift ×1
swift2 ×1