小编Sar*_*den的帖子

Android:静态方法中的getString(R.string)

在为Android编程时,有时您必须使用静态方法.但是当您尝试以静态方法访问资源时,getString(R.string.text)您将收到错误.使其静止不起作用.

有没有人知道这个好方法?Android中的资源文件对于使用不同语言创建内容或更改文本非常有用.

static android getstring

27
推荐指数
4
解决办法
3万
查看次数

自定义attr获取颜色返回无效值

我有一个自定义视图,我想在其中设置textview的颜色.

我有

attrs.xml

<declare-styleable name="PropertyView">
    <attr name="propertyTitle" format="string" localization="suggested" />
    <attr name="showTitle" format="boolean" />
    <attr name="propertyTextColor" format="color" />
    <attr name="propertyTextSize" format="dimension" />
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)

我在布局文件中设置它

<com.something.views.PropertyView
    android:id="@+id/dwf_rAwayTeamTimePenaltyInput"
    style="@style/mw"
    propertyview:propertyTextSize="16sp"
    propertyview:propertyTitle="@string/AwayTeam"
    propertyview:showTitle="true"
    propertyview:propertyTextColor="@color/textLight" />
Run Code Online (Sandbox Code Playgroud)

在我的代码中我设置它

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PropertyView, 0, 0);

    showTitle = a.getBoolean(R.styleable.PropertyView_showTitle, false);
    String title = a.getString(R.styleable.PropertyView_propertyTitle);
    float textSize = a.getDimension(R.styleable.PropertyView_propertyTextSize, -1);
    int color = a.getColor(R.styleable.PropertyView_propertyTextColor, -1);
    textSize = textSize / getResources().getDisplayMetrics().scaledDensity;
    if(BuildConfig.DEBUG) Log.e(getClass().getName(), "Color set to: " + color);

    setShowTitle(showTitle);
    setTitle(title);
    if(textSize >= 0) mTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    if(color != …
Run Code Online (Sandbox Code Playgroud)

android android-custom-view

24
推荐指数
3
解决办法
2万
查看次数

AsyncUdpSocket如何使用receive

我正在尝试在模拟器上运行iPhone程序.我的问题是接收UDP数据.我使用asyncUdpSocket.如果我做一个插座并使用sendData:(NSData) toHost:,......好吧它工作正常.

想想我可能无法弄清楚接收功能是如何工作的.

我假设这样的事情:

socket = [[AsyncUdpSocket alloc] initWithDelegate:self];
[socket bindToPort:8000] error:nil] //returns YES
[socket receiveWithTimeout:-1 tag:1];  
Run Code Online (Sandbox Code Playgroud)

我相信它应该调用该方法 -(BOOL)onUdpSocket:(AsyncUdpSocket *)sock didReceiveData:(NSData *)data withTag:(long) fromHost:(NSString *)host port:(UInt16)port

好吧,我在该方法中放置了一个NSLog,它永远不会被调用.那么[socket receive,..]是唯一的接收方法,所以我想它应该是那个...或者是否有另一种方法我必须使用?或者我必须为我的代表或其他任何东西做一些补充......我只是无法弄清楚我是如何做到的

我搜索了asyncUdpSocket示例,教程,如何('s)等等,但我找不到一个例子.因此,如果有人想解释它或知道坐在一个很好的解释,将非常感激.

如果您还不知道答案,那么无论如何都要阅读!

iphone cocoa-touch udp asyncsocket

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

Xcode 警告:多个目标匹配产品的隐式依赖项

我有一个有两种风格的应用程序(付费和免费)。我的框架之一叫做 AppBootstrap,它有两个子规范(FreeVersion 和 PaidVersion)

现在 Xcode 不断给出这个烦人的警告(我的目标是在我的项目中零警告,所以我不想忽略它,滑坡之类的东西;))

Multiple targets match implicit dependency for product reference 'AppBootstrap.framework'. Consider adding an explicit dependency on the intended target to resolve this ambiguity. (in target 'The Flight Tracker Free' from project 'The Flight Tracker')
Target 'AppBootstrap-FreeVersion' (in project 'AppBootstrap')
Target 'AppBootstrap-PaidVersion' (in project 'AppBootstrap')
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索了一下,但我找不到如何解决这个问题。我尝试 * 在“链接二进制与库”构建阶段添加它,但这并没有解决它。* 将它添加到依赖项阶段,但它们没有出现在那里。* 将“构建设置 => 其他链接器标志”中的“-framework AppBootstrap”更改为“-framework AppBootstrap-FreeVersion”,但最终会出错。

我的 podfile(简化)

source 'custom-pods/link'
source 'https://cdn.cocoapods.org/'

platform :ios, '9.0'

install! 'cocoapods',
  :generate_multiple_pod_projects => true,
  :incremental_installation => true

use_frameworks!
inhibit_all_warnings!

workspace 'MyApp' …
Run Code Online (Sandbox Code Playgroud)

xcode cocoapods

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

Sourcetree无法打开Diffmerge进行合并冲突

最近,我重新安装了macOS。我已经安装了Sourctree和diffmerge并将diffmerge设置为默认合并工具。出于某种原因,每次我选择“解决冲突->打开外部合并工具”时,sourcetree都会打开其等待视图并直接将其关闭。

我在sourcetree中的设置页面:

在此处输入图片说明

这是当sourcetree为我配置diff合并时我的根.gitconfig的样子:

[core]
    excludesfile = /Users/[username]/.gitignore_global
[user] 
    name = ---- -----
    email = -----@-----.--
[commit]
    template = /Users/[username]/.stCommitMsg
[credential]
    helper =  !/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/java -Ddebug=false -Djava.net.useSystemProxies=true -jar /usr/local/Cellar/git-credential-manager/2.0.4/libexec/git-credential-manager-2.0.4.jar

[difftool "DiffMerge"]
[mergetool "DiffMerge"]
[diff]
    tool = diffmerge
[difftool "diffmerge"]
    cmd = /usr/local/bin/diffmerge \"$LOCAL\" \"$REMOTE\"
[merge]
    tool = diffmerge
[mergetool "diffmerge"]
    trustExitCode = true
    cmd = /usr/local/bin/diffmerge --merge --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"
[difftool "sourcetree"]
    cmd = /Applications/DiffMerge.app/Contents/MacOS/DiffMerge/Contents/MacOS/DiffMerge --nosplash \"$LOCAL\" \"$REMOTE\"
path = 
[mergetool "sourcetree"]
    cmd = /Applications/DiffMerge.app/Contents/MacOS/DiffMerge/Contents/MacOS/DiffMerge --merge --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"
    trustExitCode …
Run Code Online (Sandbox Code Playgroud)

diffmerge atlassian-sourcetree

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

IOS self-> isa已弃用,但Object_setClass也发出警告

我正忙着一个大脑库.在他的代码中,他设置了几次.这仍然有效但正式弃用.替代方案应该是object_setClass函数.但是当我替换它时,我得到一个警告:函数'object_setClass'的隐式声明在C99中无效. 也许我错过了一个导入或什么?有人有想法吗?谢谢.

if(nodePtr->type == XML_ELEMENT_NODE)
{
    self->isa = [DDXMLElement class];
    //object_setClass(self, [DDXMLElement class]);
}
else if(nodePtr->type == XML_DOCUMENT_NODE)
{
    self->isa = [DDXMLDocument class];
    //object_setClass(self, [DDXMLDocument class]);
}
Run Code Online (Sandbox Code Playgroud)

objective-c isa ios

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

iOS 模拟器崩溃,设备不崩溃(dyld:找不到符号)

我花了一些时间来解决这个问题,所以我想如果有人搜索过它,他们也可能会在这里找到解决方案。

当我有一个名为 CoreUI 的框架时,问题就出现了。这在我的 iPhone 和 iPad 上运行良好,但它在模拟器上崩溃,终端出现以下错误

dyld: Symbol not found: _OBJC_CLASS_$_CUICatalog
Referenced from: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit
Expected in: /Users/sareninden/Library/Developer/Xcode/DerivedData/Treinplanner-bcfwuvntuwetsmavibxtvaiczpfg/Build/Products/Debug-iphonesimulator/CoreUI.framework/CoreUI
 in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit
Run Code Online (Sandbox Code Playgroud)

在查看所有构建设置并没有发现任何内容后,我尝试使用名为 CoreUI 的框架创建一个空项目。如果没有添加任何逻辑,它就会因相同的错误而崩溃。

模拟器中的CoreUI似乎也是苹果公司使用的框架名称。即使它是一个 swift only 框架,这仍然会导致冲突。

crash frameworks ios ios-simulator swift

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