小编Pol*_*les的帖子

如果"let"关键字用于在swift中定义常量/不可变,那么"static"关键字的用途是什么?

我对在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关键字以及letvar关键字.谁能解释一下我在哪里使用这个静态关键字?更重要的是我们真的需要swift的静态吗?

static constants swift

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

Xcode 9 iOS模拟器在安装Xcode 10 beta后变为黑屏

我知道有很多人早些时候提过这个问题.但我认为我的情况有所不同.在我的情况下,Xcode 9.2已经安装,我将macOS从10.13.2升级到10.13.5.然后我安装了Xcode 10 beta.现在,当我在Xcode 9.2上运行任何项目并尝试使用模拟器时,虽然我可以看到xcode日志,但它变黑了.我到目前为止尝试过的事情,

  1. 卸载Xcode 10 Beta
  2. 卸载并重新安装Xcode 9.2
  3. 卸载Xcode 9.2并安装Xcode 9.4
  4. 从模拟器菜单重置内容和设置
  5. 从模拟器菜单重启设备
  6. 调整模拟器的大小.
  7. 按照这篇文章,清理了DerivedData,CoreSimulator,iOSDeviceSupport
  8. 从设备和模拟器部分重新添加模拟器

现在我该怎么办?

xcode ios ios-simulator xcode9.2 xcode10

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

使用"联系人"框架获取本地化的电话标签

我正在尝试使用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中已弃用.

ios cncontact cncontactstore contacts-framework

10
推荐指数
2
解决办法
2490
查看次数

在highcharts中按名称或ID删除系列

反正有没有按名称或身份删除系列?我的意思是有可能删除系列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()有可能吗?

javascript highcharts

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

什么是mysql/magento中的Varien_Db_Ddl_Table :: TYPE_TEXT

我在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 '吗?

php mysql ddl magento

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

无法连接到iOS企业应用程序中的example.com

我面临一个严重的问题.我正在努力使企业应用程序生效.通过使用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)

ssl-certificate ios ios-enterprise

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

在QLPreviewController中隐藏右侧缩略图栏

当我将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的导航栏.

ios qlpreviewcontroller

6
推荐指数
0
解决办法
267
查看次数

SIP代理和SIP出站代理之间的区别

我对Sip代理和SIP出站代理感到有些困惑?sip代理和sip出站代理之间的基本区别是什么?是否必须将sip出站代理与sip代理一起使用?谁能从下图中指出我是sip代理和出站代理?

在此处输入图片说明

voip sip outbound sip-server

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

将UIWebView转换为PDF/Image只能输出一英寸宽的输出

我正在使用以下代码将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)

pdf objective-c uiwebview ios uigraphicscontext

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

如何用纯javascript创建和写入临时文件?

我有一个 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。

javascript

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