我想知道我即将完成的应用程序。它导致 CPU 使用率始终高于 100%,即使我的 iPhone 不执行任何操作,它也会变得非常热。
我的应用程序只是从互联网加载一些 json 并显示一些图像和文本。一开始我有一个旋转图像来显示加载过程,差不多就是这样。
我不知道如何找到导致使用的部分。
这是两个坏人,但我不知道他们做什么以及他们来自哪里:
它是如此连线,我的 mainView 是一个 Tableview,如果我什么都不做,我的 CPU 使用率就会超过 100%,如果我上下滚动,它会下降到 70%/80%。
我想写一个带字符串和字典的方法.该方法应扫描字符串并将{word}内的每个单词替换为dic ["word"]的值.
例:
s = "Hello my name is {name} and I like {thing}"
dic = {"name": "Mike", "thing": "Plains"}
def rep(s, dic):
return "Hello my name is Mike and I like Plains"
Run Code Online (Sandbox Code Playgroud)
我的意思是它是一个简单的问题,易于解决,但我搜索了很好的python方式.
在我的values文件夹中,我有my_colors.xml:
<resources>
<!-- Orange -->
<color name="orangePrimary">#f6a02d</color>
<color name="orange1">#e3952a</color>
<color name="orange2">#da8f28</color>
<color name="orange3">#d08926</color>
</resources>
Run Code Online (Sandbox Code Playgroud)
有没有办法让这些颜色只是用它的名字串?就像是view.setBackgroundColor.getColor("orange1");
对于图像,你有这个 getResources().getIdentifier("my_image", "drawable", getPackageName());
希望你们知道我的意思.问候.
我有一个 WrapPanel,我正在用 UserControls 填充我的 ViewModel:
<WrapPanel Width="250" Orientation="Horizontal" Margin="3">
<ItemsControl ItemsSource="{Binding PlaceableObjectsContent}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:PlaceableObjectViewModel}">
<local:PlaceableObjectUserControl>
<local:PlaceableObjectUserControl.InputBindings>
<MouseBinding MouseAction="LeftClick"
Command="{Binding DataContext.OnPlaceableObjectClicked, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
CommandParameter="{Binding}"/>
</local:PlaceableObjectUserControl.InputBindings>
</local:PlaceableObjectUserControl>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</WrapPanel>
Run Code Online (Sandbox Code Playgroud)
当我用随机控件填充它们时,一切正常!我已经阅读了一些关于由于使用 ItemTemplate 的问题!?如果是真的,我该如何管理?
谢谢
string ×2
android ×1
c# ×1
colors ×1
cpu-usage ×1
ios ×1
itemscontrol ×1
itemtemplate ×1
performance ×1
python ×1
swift ×1
wpf ×1
wrappanel ×1