我对在swift中使用static关键字感到有些困惑.正如我们所知,swift引入了let关键字来声明不可变对象.就像声明一个表视图单元的id一样,它最有可能在其生命周期内不会改变.现在什么是在一些struct的声明中使用static关键字:
struct classConstants
{
static let test = "test"
static var totalCount = 0
}
Run Code Online (Sandbox Code Playgroud)
而let关键字也是这样.在Objective C中,我们使用static来声明一些常量
static NSString *cellIdentifier=@"cellId";
Run Code Online (Sandbox Code Playgroud)
除此之外让我更好奇的是使用static关键字以及let和var关键字.谁能解释一下我在哪里使用这个静态关键字?更重要的是我们真的需要swift的静态吗?
我知道有很多人早些时候提过这个问题.但我认为我的情况有所不同.在我的情况下,Xcode 9.2已经安装,我将macOS从10.13.2升级到10.13.5.然后我安装了Xcode 10 beta.现在,当我在Xcode 9.2上运行任何项目并尝试使用模拟器时,虽然我可以看到xcode日志,但它变黑了.我到目前为止尝试过的事情,
现在我该怎么办?
我正在尝试使用CNContact.My获取本地化的电话标签值到目前为止:
NSError *error = nil;
CNContactFetchRequest *fetchRequest =[[CNContactFetchRequest alloc] initWithKeysToFetch:keysToFetch];
[addressBook enumerateContactsWithFetchRequest:fetchRequest error:&error usingBlock:^(CNContact * _Nonnull contact, BOOL * _Nonnull stop) {
CNLabeledValue *phoneNumberValue = contact.phoneNumbers.firstObject;
NSString *label = phoneNumberValue.label;
NSLog(@"Phone Label: %@",label); //Logs value like _$!<Home>!$_
CNPhoneNumber *phoneNumber = phoneNumberValue.value;
NSString *phoneNumberString = phoneNumber.stringValue;
NSLog(@"Phone No: %@",phoneNumberString);
}];
Run Code Online (Sandbox Code Playgroud)
问题是手机标签返回原始值,如_$!<Home>!$_,_$!<Mobile>!$_.但我需要像Home,Mobile这样的纯文本.有什么办法可以使用Contact框架获取本地化值.我不想使用Addressbook,因为它在iOS 9中已弃用.
反正有没有按名称或身份删除系列?我的意思是有可能删除系列this.remove()
要么
var seriesLength = chart.series.length;
for(var i = seriesLength - 1; i > -1; i--) {
chart.series[i].remove();
}
Run Code Online (Sandbox Code Playgroud)
但顾名思义,series_name.remove()有可能吗?
我在magento mysql安装或升级脚本中看到过,他们使用以下命令添加列:
$installer->getTable('catalog/eav_attribute'),
'tooltip',
array(
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'Tooltip'
)
Run Code Online (Sandbox Code Playgroud)
我想知道什么是Varien_Db_Ddl_Table :: TYPE_TEXT?如果我想在mysql表中手动添加工具提示列,那么我应该在类型部分中使用什么?它只是' TEXT '吗?
我面临一个严重的问题.我正在努力使企业应用程序生效.通过使用BetaBuilder我遵循以下步骤:
myApp.ipa
manifest.plist
index.html
Run Code Online (Sandbox Code Playgroud)
manifest.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>https://example.com/ios/myapp.ipa</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.com.myapp</string>
<key>bundle-version</key>
<string>1.0</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>Myapp</string>
</dict>
</dict>
</array>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)
和index.html文件:
<!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" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>Myapp - Beta Release</title>
</head>
<body>
<div id="container">
<h1>iOS 4.0 Users:</h1>
<div …Run Code Online (Sandbox Code Playgroud) 当我将QLPreviewController添加为childviewcontroller时,我无法隐藏正确的缩略图栏.我正在使用以下代码:
#import <QuickLook/QuickLook.h>
-(void)viewDidLoad
{
if ([QLPreviewController canPreviewItem:[[NSBundle mainBundle] URLForResource:@"myFile" withExtension:@"pdf"]])
{
QLPreviewController *previewController = [[QLPreviewController alloc] init];
previewController.dataSource = self;
[self addChildViewController:previewController];
[viewQuickLook addSubview:previewController.view];
[previewController didMoveToParentViewController:self];
}
}
-(NSInteger) numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
return 1;
}
- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"myFile" withExtension:@"pdf"];
return pdfURL;
}
Run Code Online (Sandbox Code Playgroud)
当我使用以下代码时,我可以隐藏缩略图栏.
QLPreviewController *previewController = [[QLPreviewController alloc] init];
previewController.dataSource = self;
[self presentViewController:previewController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
但我不想要QLPreviewController的导航栏.
我正在使用以下代码将UIWebView转换为pdf/image:
NSString *heightStr = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
int height = [heightStr intValue];
CGFloat screenHeight = webView.bounds.size.height;
int pages = ceil(height / screenHeight);
NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, webView.bounds, nil);
CGRect frame = [webView frame];
NSMutableArray *imageArray= [[NSMutableArray alloc]init];
for (int i = 0; i < pages; i++)
{
// Check to screenHeight if page draws more than the height of the UIWebView
if ((i+1) * screenHeight > height)
{
CGRect f = [webView frame];
f.size.height -= (((i+1) * screenHeight) - …Run Code Online (Sandbox Code Playgroud) 我有一个 xml 内容,我想将其写入临时 xml 文件,然后提示用户保存它。我有这个...
var xml_content = document.getElementById('content_xml').value;
var downloadable=encodeURIComponent(xml_content);
document.location= 'data:Application/octet-stream,' +downloadable;
Run Code Online (Sandbox Code Playgroud)
请帮我一个纯javascript代码,我的意思是没有jquery。