小编Dom*_*que的帖子

如何在iOS中的UILabel上显示HTML字符串?

我正在获得HTML格式的标题

<p> <span style ="color:#000000;"> <strong>示例</ strong> </ span> </ p>

我需要在UILabel中显示这个HTML字符串.颜色代码和字体大小应与HTML中的相同.当我将HTML字符串转换为NSString时,只有文本"示例"即将到来,而不是颜色.

有什么解决方案吗?

Thnx提前

直到现在我尝试通过以下方式使用NSAttributedString,但通过这种方式整个HTML正在打印:

UIFont *font = [UIFont systemFontOfSize:14.0];
UIFont *secondFont = [UIFont systemFontOfSize:10.0];

NSMutableDictionary *firstAttributes;
NSMutableDictionary *secondAttributes;

NSDictionary *firstAttributeFont = @{NSFontAttributeName:font};
NSDictionary *secondAttributeFont = @{NSFontAttributeName:secondFont};

[firstAttributes addEntriesFromDictionary:firstAttributeFont];
[secondAttributes addEntriesFromDictionary:secondAttributeFont];

[firstAttributes addEntriesFromDictionary:@{NSForegroundColorAttributeName:[UIColor clearColor]}];
[secondAttributes addEntriesFromDictionary:@{NSForegroundColorAttributeName:[UIColor clearColor]}];



NSString* completeString = [NSString stringWithFormat:@"%@",strTitle];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]     initWithString:completeString];
[attributedString setAttributes:firstAttributes range:[completeString rangeOfString:strTitle]];
//   [attributedString setAttributes:secondAttributes range:[completeString rangeOfString:self.secondAttributeText]];
Cell.lbl_Title.attributedText = attributedString;
Run Code Online (Sandbox Code Playgroud)

ios

50
推荐指数
5
解决办法
6万
查看次数

如何使用工具:overrideLibrary具有多个库

我想创建一个与API级别4兼容的Android项目,但仍希望使用UiAutomator测试它,这需要在较新的设备上使用API​​级别18.因此,应用程序也可以在旧设备上运行,但自动测试将在新设备上执行.

因此,我使用Android Studio创建了一个新项目,并添加了UiAutomator测试库:

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  compile 'com.android.support:appcompat-v7:23.0.1'
  androidTestCompile 'com.android.support:support-annotations:23.0.1'
  androidTestCompile 'com.android.support.test:runner:0.3'
  androidTestCompile 'com.android.support.test:rules:0.3'
  androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
}
Run Code Online (Sandbox Code Playgroud)

编译时我得到了错误

Error:Execution failed for task ':app:processDebugAndroidTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 4 cannot be smaller than version 8 declared in library [com.android.support.test:runner:0.3] /Users/dom/Entwicklung/MacBookPro/git/GradleTest/app/build/intermediates/exploded-aar/com.android.support.test/runner/0.3/AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="android.support.test" to force usage
Run Code Online (Sandbox Code Playgroud)

添加

<uses-sdk tools:overrideLibrary="android.support.test"/>
Run Code Online (Sandbox Code Playgroud)

到AndroidManifest.xml会导致另一个错误:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 4 cannot be smaller than version 7 declared in library [com.android.support:appcompat-v7:23.0.1] …
Run Code Online (Sandbox Code Playgroud)

android android-studio android-gradle-plugin

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