我想的setState在AsyncStorage块,但有一个错误:未定义没有(评估“this.setState”)的对象。
constructor(props){
super(props);
this.state={
activeID:this.props.data.channel[0].id
};
}
componentDidMount() {
AsyncStorage.getItem(this.props.data.type,function(errs,result){
if (!errs) {
if (result !== null) {
this.setState({activeID:result});
}
}
});
}
_buttonPressed = (id,name,index) => {
this.setState({activeID:id});
AsyncStorage.setItem(this.props.data.type,id,function(errs){
if (errs) {
console.log('error');
}
if (!errs) {
console.log('succeed');
}
});
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激,谢谢。
我发现它UITableViewCell's accessoryView在 iOS 13 上有灰色背景色,但它在系统设置中运行良好。
我试过设置UITableView背景颜色和色调颜色,它们都不起作用。
var cell = tableView.dequeueReusableCell(withIdentifier: "myInfo")
if (cell==nil) {
cell = UITableViewCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: "myInfo")
}
cell!.accessoryType = .disclosureIndicator
Run Code Online (Sandbox Code Playgroud)
Xcode 调试层次视图中的层次结构:
原因从系统 imageView 看:
我想使用 KeychainItemWrapper 将 UUID 保存在钥匙串中,因此我在MyKeychainManager.m中添加以下方法:
#define keychain_idenentify @"com.myapp.bundle1"
+ (void)saveUUID:(NSString *)UUID{
if([MyKeychainManager getUUID].length > 0) {
return;
}
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc]initWithIdentifier:keychain_idenentify accessGroup:nil];
[keychain setObject:UUID forKey:(__bridge id)kSecAttrLabel];
}
+ (NSString *)getUUID {
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc]initWithIdentifier:keychain_idenentify accessGroup:nil];
NSString *uuidString = [keychain objectForKey:(__bridge id)kSecAttrLabel];
return uuidString;
}
Run Code Online (Sandbox Code Playgroud)
但是当我将keychain_identify更改为com.otherApp.bundle后,它崩溃了
结果 = SecItemAdd((CFDictionaryRef)[selfdictionaryToSecItemFormat:keychainItemData], NULL); NSAssert( result == noErr, @"无法添加钥匙串项目。" );
错误是错误 - 25299
这是为什么以及如何解决这个问题?我应该选择哪个,例如kSecAttrLabel?我将其更改为kSecAttrService它很有趣,但我不知道是否还有其他潜在的错误。
任何帮助将不胜感激。