很明显如何使用高程属性绘制阴影但是如果我想让阴影居中怎么办?
假设我有一些将泛型类型作为参数的函数。如何在该函数中检查泛型类型参数是否可为空?我想做这样的事情:
void func<T>() {
print(T is nullable);
}
void main(){
func<int>(); //prints false
func<int?>(); //prints true
}
Run Code Online (Sandbox Code Playgroud)
我能想到的就是检查是否T.toString()以?非常hacky 的结尾。
我正在参加斯坦福iOS课程(对不起,我是其中一个人,但我想以某种方式学习)我正在使用的代码与教授关于MKMapViews的代码几乎完全相同但是我得到了这个例外,他没有,我真的无法理解.可能是什么导致了这个?
我得到的例外:
- [NSConcreteData _isResizable]:发送到实例0x90a4c00的无法识别的选择器
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
MKAnnotationView *aView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"MapVC"];
if (!aView) {
aView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"MapVC"];
aView.canShowCallout=YES;
aView.leftCalloutAccessoryView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
aView.rightCalloutAccessoryView= [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
aView.annotation=annotation;
[(UIImageView *)aView.leftCalloutAccessoryView setImage:nil];
return aView;
}
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
UIImage *image = [self.delegate getImageForMapViewController:self withAnnotation:view.annotation];
[(UIImageView *)view.leftCalloutAccessoryView setImage:image]; // this is where I get the exception.
}
Run Code Online (Sandbox Code Playgroud)