小编Giu*_*isi的帖子

我如何在swift中将字体更改为UITextView?

Hy家伙我想要我textView有这个字体:"Apple SD Gothic Light"...我在这里使用此代码属于:

if (titolo.text == NSLocalizedString("SEVENTH_ANNOTATION_TITLE", comment: "")){
    // aggiungo le immagini all'array
    pageImages = [UIImage(named: "TeatroMassimoBellini1.png")!,
                  UIImage(named: "TeatroMassimoBellini2.png")!,
                  UIImage(named: "TeatroMassimoBellini3.png")!]

    textFieldDescrizione.text = NSLocalizedString("SEVENTH_ANNOTATION_DESCRIPTION", comment: "")
    textFieldDescrizione.font = UIFont.preferredFontForTextStyle("AppleSDGothicNeo-Light")
    textFieldDescrizione.textAlignment = NSTextAlignment.Justified
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用....你能帮助我吗?对不起我的英语不好!:)

fonts ios swift

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

操作无法完成。(kCLErrorDomain 错误 1。)

我对这个问题的标题有同样的问题:

操作无法完成。(kCLErrorDomain 错误 1。)

此错误是当用户按下不允许本地化访问权限时。这是我的代码:

 @IBAction func getLocation(sender: UIButton)
{

    // i servizi di localizzazione sono abilitati?
    if (CLLocationManager.locationServicesEnabled())
    {
        // abbiamo l'autorizzazione ad accedere ai servizi di localizzazione?
        switch CLLocationManager.authorizationStatus(){
        case .Denied:
            // NO
            displayAlertWithTitle("Denied", message: "Location services are not allowed for this app")
        case .NotDetermined:
            // NON SAPPIAMO, DOBBIAMO CHIEDERE
            self.locationManager = CLLocationManager()
            if (locationManager != nil)
            {
                locationManager.delegate = self
                locationManager.desiredAccuracy = kCLLocationAccuracyBest
                locationManager.requestWhenInUseAuthorization()
                locationManager.startUpdatingLocation()
            }
        case .Restricted:
            // SONO STATE APPLICATE DELLE RESTRIZIONI, NON ABBIAMO ACCESSO …
Run Code Online (Sandbox Code Playgroud)

core-location swift

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

在 mapView 中为 CLLocation 数组绘制路线(Swift)

如何在 mapview 中为 CLLocation 数组创建路线?我创建了一条折线,我想通过步行创建一条路线。这是我的代码:

@IBAction func addPolyline(sender: AnyObject) {
    let locations = [CLLocation(latitude: annotazioni.objectAtIndex(0).coordinate.latitude, longitude:annotazioni.objectAtIndex(0).coordinate.longitude ),
                     CLLocation(latitude: annotazioni.objectAtIndex(1).coordinate.latitude, longitude:annotazioni.objectAtIndex(1).coordinate.longitude ),
                     CLLocation(latitude: annotazioni.objectAtIndex(2).coordinate.latitude, longitude:annotazioni.objectAtIndex(2).coordinate.longitude ),
                     CLLocation(latitude: annotazioni.objectAtIndex(3).coordinate.latitude, longitude:annotazioni.objectAtIndex(3).coordinate.longitude ),
                     CLLocation(latitude: annotazioni.objectAtIndex(4).coordinate.latitude, longitude:annotazioni.objectAtIndex(4).coordinate.longitude ),
                     CLLocation(latitude: annotazioni.objectAtIndex(5).coordinate.latitude, longitude:annotazioni.objectAtIndex(5).coordinate.longitude ),
                     CLLocation(latitude: annotazioni.objectAtIndex(6).coordinate.latitude, longitude:annotazioni.objectAtIndex(6).coordinate.longitude )]
    addPolyLineToMap(locations)
}
func addPolyLineToMap(locations: [CLLocation!]){
    var coordinates = locations.map({ (location: CLLocation!) -> CLLocationCoordinate2D in
        return location.coordinate
    })
    let geodesic = MKGeodesicPolyline(coordinates: &coordinates, count: locations.count)
    mapView.addOverlay(geodesic)

}
func mapView(mapView: MKMapView!, viewForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! {

    if (overlay is MKPolyline) …
Run Code Online (Sandbox Code Playgroud)

routes polyline cllocation swift

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

从 pytorch 中预训练的 resnet50 中提取特征

大家好,我想提取预训练 resnet50 的全连接层的 in_features。

我之前创建了一个为我提供特征向量的方法:

def get_vector(image):

#layer = model._modules.get('fc')

layer = model.fc
my_embedding = torch.zeros(2048) #2048 is the in_features of FC , output of avgpool

def copy_data(m, i, o):

    my_embedding.copy_(o.data)


h = layer.register_forward_hook(copy_data)
tmp = model(image)

h.remove()

# return the vector
return my_embedding
Run Code Online (Sandbox Code Playgroud)

我在这里调用这个方法之后:

column = ["FlickrID", "Features"]

path = "./train_dataset/train_imgs/"

pathCSV = "./train_dataset/features/img_info_TRAIN.csv"



f_id=[]
features_extr=[]

df = pd.DataFrame(columns=column)


tr=transforms.Compose([transforms.Resize(256),
                       transforms.CenterCrop(224),
                       transforms.ToTensor(),
                       transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])



test = Dataset(path, pathCSV, transform=tr)

test_loader = DataLoader(test, batch_size=1, num_workers=2, shuffle …
Run Code Online (Sandbox Code Playgroud)

python resnet pytorch

-1
推荐指数
1
解决办法
5846
查看次数

标签 统计

swift ×3

cllocation ×1

core-location ×1

fonts ×1

ios ×1

polyline ×1

python ×1

pytorch ×1

resnet ×1

routes ×1