小编Sam*_*yan的帖子

真的1 KB(KiloByte)等于1024字节?

到目前为止,我认为1024字节等于1 KB(千字节),但我正在互联网上阅读十进制和二进制系统.

在此输入图像描述

那么,实际上1024字节= 1 KB是正确的定义方式还是只是存在一般性的混淆?

binary byte system decimal bit

53
推荐指数
3
解决办法
8万
查看次数

如何将Google MapView放入UIView?

我正在尝试将Google MapView放入,UIView但我没有显示任何内容.

我的代码,

*.H

#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>

@interface ViewController : UIViewController

@property (weak, nonatomic) IBOutlet UIBarButtonItem *btnLocate;
@property (weak, nonatomic) IBOutlet GMSMapView *mapView_;
@property (weak, nonatomic) IBOutlet UIView *mapView;

@end
Run Code Online (Sandbox Code Playgroud)

*.M

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                            longitude:151.20
                                                                 zoom:6];
    self.mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    self.mapView_.myLocationEnabled = YES;
    self.mapView = self.mapView_;
Run Code Online (Sandbox Code Playgroud)

谢谢.

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                            longitude:151.20
                                                                 zoom:6];

    // Indicating the map frame bounds
    self.mapView_ = [GMSMapView mapWithFrame:self.mapView.bounds camera: camera]; 
    self.mapView_.myLocationEnabled = YES;

    // Add as subview …
Run Code Online (Sandbox Code Playgroud)

uiview ios google-maps-sdk-ios

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

将文件的字节数组加载到内存中

我正在尝试将jar文件直接加载到内存中而不将其丢弃到HDD中.我尝试过使用ClassLoader,但是我收到了一个错误.

这是我的代码:

自定义类加载器

public class CLS_ClassLoader extends ClassLoader {

    private byte[] bArrData;

    public CLS_ClassLoader(ClassLoader parent, byte[] bArrData) {
        super(parent);

        this.bArrData = bArrData;
    }

    public Class<?> loadClass(String name) throws ClassNotFoundException {
        return defineClass(name, bArrData, 0,
                bArrData.length);
    }
}
Run Code Online (Sandbox Code Playgroud)

主要

ClassLoader tParentClsLoader = CLS_ClassLoader.class.getClassLoader();
CLS_ClassLoader tClsLoader = new CLS_ClassLoader(tParentClsLoader, fileToByteArray("D:/App.jar"));
Class<?> tClass = null;

try {
        tClass = tClsLoader.loadClass("pkg_main.CLS_Main");
} catch (ClassNotFoundException e) {
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

产量

Exception in thread "main" java.lang.ClassFormatError: Incompatible magic value 1347093252 in class file pkg_main/CLS_Main
    at java.lang.ClassLoader.defineClass1(Native …
Run Code Online (Sandbox Code Playgroud)

java memory encryption runtime classloader

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

WPF 控件图像在 WinForms 中失败

我是 WPF 菜鸟。我有一个选项卡控件,选项卡上有一个图标。当我通过 ElementHost 将其导入 winforms 中的控件时,该图标不会出现在选项卡上。我从资源加载图标图像。

在此输入图像描述

XAML 代码:

<UserControl x:Class="WPF_Prueba.TabControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        <ResourceDictionary>
            <BitmapImage x:Key="tabIcon" UriSource="/Resources/delete.png" />
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
        <TabControl Name="tabDynamic" ItemsSource="{Binding}" SelectionChanged="tabDynamic_SelectionChanged">
            <TabControl.Resources>
                <DataTemplate x:Key="TabHeader" DataType="TabItem">
                    <DockPanel>
                        <Button Name="btnDelete" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" DockPanel.Dock="Right" Background="Transparent" Margin="5,0,-3,0" Padding="0" Click="btnDelete_Click" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=Name}">
                            <Image Source="{StaticResource tabIcon}" Height="10" Width="10"></Image>
                        </Button>
                        <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=TabItem}, Path=Header}" />
                    </DockPanel>
                </DataTemplate>
            </TabControl.Resources>
        </TabControl>
    </Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

如果有人可以帮助我。抱歉,有错别字。

此致。

c# wpf image winforms

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

代码从C/C++转换为Delphi

我有一点问题.我想将一些代码从C/C++翻译成Delphi.

LPVOID lpMyVar;

*(LPWORD)lpMyVar = 0xF9EB;
Run Code Online (Sandbox Code Playgroud)

我尝试了几种方法,但无济于事.如果有人可以帮助我.提前致谢!

c++ delphi translate

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

Facebook SDK 4自定义按钮(Android)

我正在尝试自定义Facebook SDK 4.0(Android)中的登录按钮但是没办法...我正在查看Fb文档,但没有结果.有什么好主意吗?

提前致谢!

android facebook button styling

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

将阵列复制到另一个阵列

我试图将一个数组的内容复制到另一个数组而不指向相同的内存,但我不能.

我的代码:

class cPrueba {
    private float fvalor;

    public float getFvalor() {
        return fvalor;
    }

    public void setFvalor(float fvalor) {
        this.fvalor = fvalor;
    }
}

List<cPrueba> tListaPrueba = new ArrayList<cPrueba>();
List<cPrueba> tListaPrueba2 = new ArrayList<cPrueba>();

cPrueba tPrueba = new cPrueba();
tPrueba.setFvalor(50);
tListaPrueba.add(tPrueba);

tListaPrueba2.addAll(tListaPrueba);
tListaPrueba2.get(0).setFvalor(100);

System.out.println(tListaPrueba.get(0).getFvalor());
Run Code Online (Sandbox Code Playgroud)

结果是"100.0"....

仍然指向同一个对象...任何简短的复制方式?(不适用于(..){})

编辑:

class cPrueba implements Cloneable {
    private float fvalor;

    public float getFvalor() {
        return fvalor;
    }

    public void setFvalor(float fvalor) {
        this.fvalor = fvalor;
    }

    public cPrueba clone() {
        return this.clone();
    }
} …
Run Code Online (Sandbox Code Playgroud)

java arrays copy

0
推荐指数
1
解决办法
116
查看次数

SHA1 Hash Delphi与Python

我尝试在delphi和python中散列相同的字符串,但我得到不同的哈希?

蟒蛇:

d = bytes('pr', 'utf-8')
print((sha1(d).digest()).hex())

output: 5498d9b96ed2832e04a90c4ac2ab71f869b2bfdc
Run Code Online (Sandbox Code Playgroud)

德尔福XE7:

...
bytes := TEncoding.UTF8.GetBytes('pr');
BinToHex(sha1Digest2(bytes);
...
output: 1ca1a00b40b8350d15cdce2935965d88b7798719


Function TForm1.sha1Digest2(buffer: TBytes): TBytes;
Var
  HashSHA1: THashSHA1;
Begin
  HashSHA1 := THashSHA1.Create;
  HashSHA1.Update(buffer, SizeOf(buffer));
  Result := HashSHA1.HashAsBytes;
End;

Function TForm1.binToHex(Const bin: Array Of Byte): String;
Const
  HexSymbols = '0123456789ABCDEF';
Var
  I: Integer;
Begin
  SetLength(Result, 2 * Length(bin));
  For I := 0 To Length(bin) - 1 Do
  Begin
    Result[1 + 2 * I + 0] := HexSymbols[1 + bin[I] Shr 4];
    Result[1 + 2 …
Run Code Online (Sandbox Code Playgroud)

python delphi hash sha1

0
推荐指数
1
解决办法
210
查看次数