我正在构建一个iOS应用程序,并且需要能够在用户当前所在的位置放置一个引脚!出于某种原因,我一直在努力工作!我尝试了以下代码,但遇到了错误.
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
if (annotation == mapView.userLocation)
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
annView.pinColor = MKPinAnnotationColorRed;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
[annView release];
}
}
Run Code Online (Sandbox Code Playgroud)
错误是:控制可能达到非空函数的结束.
非常感谢你的帮助!'欣赏它!
我一直在尝试确定表格视图顶部的第三个单元格。基本上,这意味着从顶部算起的第三个单元格看起来总是与所有其他单元格不同(即文本颜色会发生变化等)。我想既然单元格被重用,我总是能够像这样访问第三个单元格:
if (indexPath.row == 2) {
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,它似乎不是那样工作的。当我继续打印indexPath.row数字时,数字会从 0 一直增加到 12 ......现在这是可以理解的,因为它是 cell row,但是我如何总是从顶部访问第三行。这是我采用的原始方法:
override func scrollViewDidScroll(scrollView: UIScrollView) {
let indexPath: NSIndexPath = self.tableView.indexPathsForVisibleRows![0]
if (indexPath.row == 2) {
// Print or whatever
}
}
}
Run Code Online (Sandbox Code Playgroud)
那么我怎样才能总是从 的顶部访问第三行tableView呢?
谢谢!
cell ×1
dictionary ×1
ios ×1
mkmapview ×1
nsindexpath ×1
swift ×1
uiscrollview ×1
uitableview ×1