小编buc*_*zek的帖子

内容安全政策指令:"框架 - 祖先'自我'

我在我的网页中嵌入了一个iFrame,如下所示:

var iframeProps = {
        'data-type': self.props.type,
        allowTransparency: self.props.allowTransparency,
        className: self.props.className,
        frameBorder: self.props.frameBorder,
        height: self.props.height,
        key: url,
        onLoad: self.props.onLoad.bind(self),
        scrolling: self.props.scrolling,
        src: self.state.isActive ? url : '',
        style: self.props.styles,
        width: self.props.width
    };
<iframe {...iframeProps} />
Run Code Online (Sandbox Code Playgroud)

这在控制台中引发了错误

拒绝在框架中显示" https://twitter.com/ ...."因为祖先违反了以下内容安全策略指令:"frame-ancestors'self'".

谁能告诉我怎样才能做到这一点?

iframe

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

UIPanGestureRecognizer在触摸时立即执行某些操作

我是ios的新手,所以如果我遗漏了一些明显的东西,我会提前道歉.

我正在制作一个拼图,我希望单个拼图在触摸时增加尺寸并减少放手.

目前我有:

-(IBAction)handlePan:(UIPanGestureRecognizer *)recognizer{
  if(recognizer.state == UIGestureRecognizerStateBegan)
  else if(recognizer.state == UIGestureRecognizerStateEnded)
}
Run Code Online (Sandbox Code Playgroud)

当平底锅开始时(也是状态开始时),拼图块增加尺寸,当平底锅结束时(如预期的那样)尺寸减小.一旦用户触摸到这件作品并且在拼图块移动之前,我希望尺寸增大.选择图块时,可以在Words With Friends中看到这一点.

我试过了

-(IBAction)handleTap:(UITapGestureRecognizer *)recognizer{
  if(recognizer.state == UIGestureRecognizerStateBegan)
  else if(recognizer.state == UIGestureRecognizerStateEnded)
}
Run Code Online (Sandbox Code Playgroud)

只有在手指抬起后才能增加拼图.

我的问题:

有一种方法可以在手指触摸拼图块后再增加拼图块的大小,然后继续摇动手势.

先感谢您.

uigesturerecognizer ios uipangesturerecognizer

13
推荐指数
3
解决办法
6016
查看次数

Swift/UIView/drawrect - 如何在需要时获取drawrect进行更新

我是学习Swift的新手,我正试图让一个非常简单的应用程序运行.我想要做的就是在按下按钮时让UIView.drawRect更新.它会在应用程序首次加载时更新/绘制,然后在我尝试之后无需更新/绘制.几天来,我一直在反对这一点,我找不到任何帮助.

我建立:

  • 单一视图应用程序

  • 一个按钮,链接到视图控制器作为动作

  • 一个新类,Test_View,子类化UIView

ViewController代码:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        var f = Test_View()

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func Button_Pressed(sender: AnyObject) {
        var f = Test_View()
        f.setNeedsDisplay()
        NSLog("Button pressed.")
    }

}
Run Code Online (Sandbox Code Playgroud)

Test_View代码:

class Test_View: UIView {

    override func drawRect(rect: CGRect) {
        let h = rect.height
        let w …
Run Code Online (Sandbox Code Playgroud)

updating uiview drawrect swift

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

UITableView获取titleForHeadersInSection swift

我想在UITableView部分设置标题的标题.swift中用于设置节中标题标题的语法是什么.

func tableView( tableView : UITableView,  titleForHeaderInSection section: Int)->String
{
    switch(section)
    {
    case 2:
        return "Title 2"
        break
    default:
        return ""
        break
    }

}

func tableView (tableView:UITableView , heightForHeaderInSection section:Int)->Float
{

    var title = tableView.titleForHeaderInSection[section];
    if (title == "") {
        return 0.0;
    }
    return 20.0;
}

func tableView (tableView:UITableView,  viewForHeaderInSection section:Int)->UIView
{

    var title = tableView.titleForHeaderInSection[section] as String
    if (title == "") {
        return UIView(frame:CGRectZero);
    }
    var headerView:UIView! = UIView (frame:CGRectMake(0, 0, self.tableView.frame.size.width, 20.0));
    headerView.backgroundColor = self.view.backgroundColor;

    return …
Run Code Online (Sandbox Code Playgroud)

uitableview swift swift-playground ios8.1

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

C:GTK + 3.0(3.20) - 从GNU/Linux(Arch Linux)到Windows的交叉编译

我需要将GNU/Linux(Arch Linux)中的GTK +应用程序交叉编译到Windows.我已经尝试过使用mingw32,但它没有看到所有库(包括c的标准库!).所以,我需要:找到标准的库; 找到所有其他(glib,gio,gtk等)库.但是有一个问题 - 我找不到它们.我也无法从Windows编译.我必须做什么?

c linux windows cross-compiling gtk3

8
推荐指数
1
解决办法
1656
查看次数

错误:无法解决:com.google.android.gms:play-services-measurement:9.2.0

将Google Play服务升级到9.2.0后,我在Gradle同步期间收到此错误.

Error:Failed to resolve: com.google.android.gms:play-services-measurement:9.2.0
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

android google-play-services android-gradle-plugin

8
推荐指数
1
解决办法
3421
查看次数

Android共享图片不起作用

我正在尝试使用以下代码共享应用程序的屏幕截图:

View content = findViewById(R.id.layoutHome);
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();

File sdCardDirectory = Environment.getExternalStorageDirectory();
File image = new File(sdCardDirectory,"temp.png");

// Encode the file as a PNG image.
FileOutputStream outStream;
try {
  outStream = new FileOutputStream(image);
  bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
  outStream.flush();
  outStream.close();
} catch (FileNotFoundException e) {
  e.printStackTrace();
} catch (IOException e) {
  e.printStackTrace();
}

String url = "file://" + sdCardDirectory.toString() + "Images/temp.png";

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("image/*");
String shareBody = "Here is the share content body";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, url); …
Run Code Online (Sandbox Code Playgroud)

android android-intent android-sdcard android-sharing

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

Android Parse JSON卡在get任务上

我试图解析一些JSON数据.我的代码工作了一段时间,我不知道我改变了什么突然破坏了代码.当我运行我的代码时,我没有收到任何运行时错误或警告.我创建一个新的AsyncTask并执行它.当我调用.get()这个新任务时,调试器在这一行停止并花费超过30分钟.我无法获得调试器或在运行期间完成此任务.

JSON:

protected void setUp(Context context) {
    _context = context;
    getConfig();
}

// get config file
protected void getConfig() { 
    if (config != null)
        return;

    config = new Config();

    String url = configURL;
    AsyncTask<String, Integer, JSONObject> jsonTask = new DownloadJSONTask()
            .execute(url);
    JSONObject configItem = null;
    try {
        configItem = jsonTask.get(); //debugger pauses here
        if (configItem == null)
            return;
        config.configVersion = configItem.getString("field_configversion");
        config.currentAppVersion = configItem
                .getString("field_currentappversion");
        config.getSupportURL = configItem.getString("field_getsupporturl");
        config.getCatalogURL = configItem.getString("field_getcatalogurl");
        config.getDataVersion = configItem.getString("field_dataversion");
        config.getDataUrl = configItem.getString("field_dataurl");
        config.getDataApiKey …
Run Code Online (Sandbox Code Playgroud)

java android json android-asynctask

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

Android中的运动识别管理器和运动服务

我的android应用无法正常运行,并且Logcat显示以下错误:

04-29 00:58:24.377 1378-1378 / com.example.tencent.coolweather E / MotionRecognitionManager:mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@1ac0fc8c

04-29 00:58:24.377 1378-1378 / com.example.tencent.coolweather E / MotionRecognitionManager:motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@11665fd5

04-29 00:58:24.377 1378-1378 / com.example.tencent.coolweather E / MotionRecognitionManager:motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@11665fd5

java android android-studio

5
推荐指数
0
解决办法
2086
查看次数

如何使用 get_theme_mod 获取图像的替代文本?

我想创建通过Wordpress 自定义功能加载徽标的可能性。当我使用插入徽标时get_theme_mod()- 它只是图像的 url,但我也想获取此图像的替代文本。

我的代码示例:

函数.php

function welbit_theme_customizer( $wp_customize ) {

    $wp_customize->add_section( 'welbit_logo_section' , array(
    'title'       => __( '???????', 'themeslug' ),
    'priority'    => 30,
    'description' => '????????? ????? ???????????.',
    ) );

    $wp_customize->add_setting( 'welbit_logo' );

    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'welbit_logo', array(
        'label'    => __( 'Logo', 'welbit' ),
        'section'  => 'welbit_logo_section',
        'settings' => 'welbit_logo',
    ) ) );
}

add_action( 'customize_register', 'welbit_theme_customizer' );
Run Code Online (Sandbox Code Playgroud)

头文件

<div class="w-header__logo">
    <a href="<?php echo get_home_url(); ?>">
       <img src="<?php print_r(get_theme_mod('welbit_logo'));?>" alt="<!-- How can I get …
Run Code Online (Sandbox Code Playgroud)

php wordpress

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