我怎样才能UISwitch在UITableView细胞上嵌入?可以在设置菜单中看到示例.
我目前的解决方案
UISwitch *mySwitch = [[[UISwitch alloc] init] autorelease];
cell.accessoryView = mySwitch;
Run Code Online (Sandbox Code Playgroud) 1.4324 =>"1.43"
9.4000 =>"9.4"
43.000 =>"43"9.4 =>"9.40"(错误)
43.000 =>"43.00"(错误)
在这两个问题中,答案都指向了NSNumberFormatter.所以应该很容易实现,但不适合我.
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, 20)];
NSNumberFormatter *doubleValueWithMaxTwoDecimalPlaces = [[NSNumberFormatter alloc] init];
[doubleValueWithMaxTwoDecimalPlaces setNumberStyle:NSNumberFormatterDecimalStyle];
[doubleValueWithMaxTwoDecimalPlaces setPaddingPosition:NSNumberFormatterPadAfterSuffix];
[doubleValueWithMaxTwoDecimalPlaces setFormatWidth:2];
NSNumber *myValue = [NSNumber numberWithDouble:0.01234];
//NSNumber *myValue = [NSNumber numberWithDouble:0.1];
myLabel.text = [doubleValueWithMaxTwoDecimalPlaces stringFromNumber:myValue];
[self.view addSubview:myLabel];
[myLabel release];
myLabel = nil;
[doubleValueWithMaxTwoDecimalPlaces release];
doubleValueWithMaxTwoDecimalPlaces = nil;
}
Run Code Online (Sandbox Code Playgroud)
我也试过了
NSString *resultString = [NSString stringWithFormat: @"%.2lf", [myValue doubleValue]]; …Run Code Online (Sandbox Code Playgroud) 开发配置文件和临时配置文件之间有什么区别?
除了商店之外,我们不能总是使用ad hoc配置文件吗?
我尝试读取CSV并回显内容.但内容显示错误的字符.
MäxMüstermänn - >MäxMüstermänn
CSV文件的编码是UTF-8,没有BOM(使用Notepad ++检查).
这是CSV文件的内容:
"Mäx";"Müstermänn"
我的PHP脚本
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
$handle = fopen ("specialchars.csv","r");
echo '<table border="1"><tr><td>First name</td><td>Last name</td></tr><tr>';
while ($data = fgetcsv ($handle, 1000, ";")) {
$num = count ($data);
for ($c=0; $c < $num; $c++) {
// output data
echo "<td>$data[$c]</td>";
}
echo "</tr><tr>";
}
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我尝试setlocale(LC_ALL, 'de_DE.utf8');按照这里的建议使用但没有成功.内容仍然显示错误.
我错过了什么?
编辑:
一个echo mb_detect_encoding($data[$c],'UTF-8');给我UTF-8 …
是否有工具显示SQLite 3数据库的数据库方案,如MySQL Workbench和Reverse Engineering?我的意思是图形表示
我有一个基于的Xamarin项目MvvmCross.该项目适用于iOS和Android.我在Visual Studio 15中打开了这个项目.我遇到了一些错误,我很快就解决了.有一些错误,即使在Google和Stackoverflow上搜索后也无法解决.我已经尝试了在Stackoverflow上找到的每个方法,但仍然存在所有剩余的错误.这个项目正在使用像RestSharp和BoxApi.V2这样的第三方库(更多)
我在下面发布我的错误日志.
Severity Code Description Project File Line Suppression State
Error The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'RestSharp(Android), Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'RestSharp(Android).dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() BoxApi.V2 (Android)
Run Code Online (Sandbox Code Playgroud)
此解决方案中包含的所有项目都会重复此错误.所以我多次收到此错误.
我还想补充说,该项目以前是在MAC上构建的,而我正在使用Windows,这是否会产生一些兼容性或跨操作系统问题?我已检查所有装配参考,所有工作正常.
我正在尝试密码保护目录,并在目录中有两个文件应该密码保护它:
.htaccess中:
###Contents of .htaccess:
AuthUserFile /var/www/html/path/to/my/directory/.htpasswd
AuthName "Protected Files"
AuthType Basic
Require user admin
Run Code Online (Sandbox Code Playgroud)
HTPASSWD:
###Contents of .htpasswd
admin:oxRHPuqwKiANY
Run Code Online (Sandbox Code Playgroud)
密码也是管理员,但无论我尝试什么密码,总是错误的.它立即再次要求输入密码!
这个配置有什么问题?
我想异步制作一个Web服务请求.我在这里称呼它:
List<Item> list = GetListAsync();
Run Code Online (Sandbox Code Playgroud)
这是我的函数的声明,它应该返回一个列表:
private async Task<List<Item>> GetListAsync(){
List<Item> list = await Task.Run(() => manager.GetList());
return list;
}
Run Code Online (Sandbox Code Playgroud)
如果我想编译我得到以下错误
Cannot implicitely convert type System.Threading.Tasks.Task<System.Collections.Generic.List<Item>> to System.Collections.Generic.List<Item>
Run Code Online (Sandbox Code Playgroud)
据我所知,如果我使用async修饰符,结果将自动包含在Task中.我认为这不会发生,因为我使用Task.Run.如果我删除了Task.Run(() =>我得到的部分
无法等待System.Collections.Generic.List表达式
我想我还没有完全理解async/await方法.我做错了什么?
我正在尝试重新实现这里UICollectionView看到的不定式滚动.对我来说遗失的东西:
ViewController.h:
@interface ViewController : UIViewController<UICollectionViewDataSource, UICollectionViewDelegate>
@end
Run Code Online (Sandbox Code Playgroud)
DataCell.h:
@interface DataCell : UICollectionViewCell
@property (nonatomic, strong) UILabel *label;
@end
Run Code Online (Sandbox Code Playgroud)
DataCell.m:
#import "DataCell.h"
@implementation DataCell
-(instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if(self){
self.label = [[UILabel alloc] initWithFrame:self.bounds];
self.autoresizesSubviews = YES;
self.label.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight);
self.label.textAlignment = NSTextAlignmentCenter;
self.label.adjustsFontSizeToFitWidth = YES;
[self addSubview:self.label];
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
CustomCollectionView.h:
@interface CustomCollectionView : UICollectionView
@end
Run Code Online (Sandbox Code Playgroud)
对于整个项目,我使用了故事板和法线UIViewController.在这个视图控制器上,我UICollectionView在Interface Builder中添加了一个.我将集合视图中的插座与视图控制器连接起来,并设置数据源并再次将方法委托给我的视图控制器.我还在UICollectionViewCellInterface Builder中设置了自定义类和重用标识符.
所以一切都应该工作,但我只得到一个黑屏.我错过了什么?您可以在此处 …
objective-c interface-builder ios infinite-scroll uicollectionview
objective-c ×4
iphone ×3
c# ×2
cocoa-touch ×2
ios ×2
.htaccess ×1
.htpasswd ×1
async-await ×1
asynchronous ×1
csv ×1
database ×1
decimal ×1
fgetcsv ×1
https ×1
list ×1
login ×1
mvvmcross ×1
php ×1
sqlite ×1
ssl ×1
task ×1
uiswitch ×1
uitableview ×1
utf-8 ×1
xamarin ×1