小编hol*_*hix的帖子

检索css3缩放元素的宽度/高度

我正在反对offsetWidth属性的奇怪(我认为).
这是场景:

我已经得到了一个span标签,在我的js中,在某一点上我对这个元素执行css3转换,如:

        el.set('styles', {
            'transform':'scale('+scale+', '+scale+')',      /* As things would be in a normal world */
            '-ms-transform':'scale('+scale+', '+scale+')',      /* IE 9 */
            '-moz-transform':'scale('+scale+', '+scale+')',         /* Moz */
            '-webkit-transform':'scale('+scale+', '+scale+')',  /* Safari / Chrome */
            '-o-transform':'scale('+scale+')'       /* Oprah Winfrey */ 
        }); 
        w = el.getWidth();
        console.log('after scaling: ' + w);
Run Code Online (Sandbox Code Playgroud)

此时日志返回模糊值,就像它不知道该说什么.
有什么建议吗?

html javascript mootools css3

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

socket.io客户端没有从服务器接收消息

我正在尝试用两个客户端实现一个系统,其中一个客户端发送一条消息,另一个客户端接收它.下图将以更直观的方式解释它:

socket.io消息通信图表

因此,客户端1将消息发送到服务器(并且这有效),服务器接收"推送"消息并发出应该由客户端2接收的"弹出"消息.这里的问题是客户端2从未收到"pop"消息.:(

这是所有这些的代码.

SERVER.JS

var app = require('express').createServer()
  , io = require('socket.io').listen(app);

app.listen(999);

app.get('/webclient', function (req, res) {
    res.sendfile(__dirname + '/web.html');
});

app.get('/mobile', function (req, res) {
    res.sendfile(__dirname + '/mobile.html');
});

io.sockets.on('connection', function (socket) {
//      socket.emit('pop', { hello: 'world' });
    socket.on('push', function (data) {
        console.log('push received, emitting a pop');
        socket.emit('pop', { hello: 'world' });
    });
});
Run Code Online (Sandbox Code Playgroud)

CLIENT 1(又名mobile.html)

<html>
    <head>
        <title>
            Mobile
        </title>
        <script src="/socket.io/socket.io.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/mootools/1.4.5/mootools-yui-compressed.js" type="text/javascript"></script>
        <script>
          var socket = io.connect('http://localhost:999');
        </script>
    </head>
    <body>
        <input type="button" name="act" …
Run Code Online (Sandbox Code Playgroud)

javascript websocket node.js socket.io

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

将网站从Symfony 1.4移植到2.0

我已经在symfony 1.4中创建了一个庞大的网站(以非常糟糕的方式),我被要求对导航流程进行一些实质性的更改,添加一些功能等等.考虑到努力,我想知道是否最好采取激进的决定将整个网站移植到symfony 2.0,但我不确定它有多难.

有没有人曾经这样做过?

您是否有任何建议可以使用模式,或者教程或文档或其他什么?

php porting symfony1 symfony-1.4 symfony

9
推荐指数
2
解决办法
5687
查看次数

核心文本视图具有黑色背景颜色


我有一个UIView使用CoreText渲染一些文本,一切正常,除了整个视图有黑色背景颜色的事实.我尝试过最基本的解决方案

[self setBackgroundColor:[UIColor clearColor]];
Run Code Online (Sandbox Code Playgroud)

要么

CGFloat components[] = {0.f, 0.f, 0.f, 0.f };
CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRef transparent = CGColorCreate(rgbColorSpace, components);
CGContextSetFillColorWithColor(context, transparent);
CFRelease(transparent);
Run Code Online (Sandbox Code Playgroud)

但这根本没有帮助.
我只是在这个问题上喋喋不休,因为我不太明白真正的核心文本是如何工作的,这个纯C层如何与所有其他Objective-c相关.这对解决这个问题没什么帮助,所以我问你们大家,你们能不能给我一个解决方案,而且(最重要的是)对它有一个解释.

FIY我也发布了CoreText视图的代码.
这一切都基于两个功能:parseText它建立了CFAttributedString和 drawRect中,是以绘图部分的护理.

-(void) parseText {
    NSLog(@"rendering this text: %@", symbolHTML);
    attrString = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
    CFAttributedStringReplaceString (attrString, CFRangeMake(0, 0), (CFStringRef)symbolHTML);

    CFStringRef fontName = (CFStringRef)@"MetaSerif-Book-Accent";
    CTFontRef myFont = CTFontCreateWithName((CFStringRef)fontName, 18.f, NULL); 
    CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
    CGFloat components[] = { 1.0, 0.3f, 0.3f, 1.f };
    CGColorRef redd = CGColorCreate(rgbColorSpace, components);
    CFAttributedStringSetAttribute(attrString, CFRangeMake(0,0), …
Run Code Online (Sandbox Code Playgroud)

core-graphics objective-c core-text

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

将canvas中的文字绘制成三个js作为精灵

长话短说,我正在制作一个实时折线图,并且由于每秒需要推入大量行,因此我正在使用three.js,因此,现在我需要绘制文本值对于 x 和 y 轴,经过相当长的斗争(因为我是一个完全的菜鸟@threejs),我想出了使用画布作为精灵的绝妙技术(这是该死的 rad )。这是我使用的代码

/// 2D REALM

var canvas = document.createElement('canvas'),
        context = canvas.getContext('2d'),
        metrics = null,
        textHeight = 100,
        textWidth = 0,
        actualFontSize = 2;

        context.fillStyle = '#FF0000';
        var size = 250;
          canvas.width = size;
          canvas.height = size;

function addText(position, text) {
  context.textAlign = 'center';
  context.font = '24px Arial';
  context.fillText("Game Over", size/2, size/2);

  var texture = new THREE.Texture(canvas);
  texture.needsUpdate = true;
  var material = new THREE.SpriteMaterial( { map: texture, color: 0x333333, fog: false } );
  var …
Run Code Online (Sandbox Code Playgroud)

javascript canvas three.js

2
推荐指数
1
解决办法
5596
查看次数

计算日期范围内的周数

我需要对一年中持续的日志进行一些基于时间的统计,我需要做的就是在确定的日期范围内计算(太阳能)周数.

即我需要计算2011年8月1日至2012年9月3日之间已经发生了多少周.以及类似的事情.

我已经有了计算两个日期之间的天数然后除以7的想法,但这不计算我可以在几周之间的事实,在这种情况下,价值不正确/精确.

以前有人遇到过类似的问题吗?

date objective-c nsdate

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

MKStoreKit非消耗品在连接和NSUbiquitousKeyValueStore都失败

我正在尝试将应用程序内购买添加到我的应用程序中,所以在想知道围绕这个互联网后我决定去找MKStoreKit,现在一切都已设置,项目看起来不错,应该在服务器上的文件,实际上是在服务器上所有这些东西.

当我在设备上运行应用程序并按下"购买"测试按钮时,混乱就开始了.首先,这是我得到的结果.

    2012-02-09 17:45:28.324 MyApp[7147:707] checking if com.my.company.testinapp.pack001 pack is purchased
    2012-02-09 17:45:30.814 MyApp[7147:707] Review request cannot be checked now: (null)
    2012-02-09 17:45:33.335 MyApp[7147:707] NSUbiquitousKeyValueStore error: com.my.company.inapp has no valid com.apple.developer.ubiquity-kvstore-identifier entitlement
    2012-02-09 17:45:33.370 MyApp[7147:707] Problem in iTunes connect configuration for product: com.my.company.testinapp.pack001
    2012-02-09 17:45:34.063 MyApp[7147:707] User cancelled transaction: <SKPaymentTransaction: 0x8c0fde0>
    2012-02-09 17:45:34.064 MyApp[7147:707] error: Error Domain=SKErrorDomain Code=3 "Cannot connect to iTunes Store" UserInfo=0x8c1f210 {NSLocalizedDescription=Cannot connect to iTunes Store}
    2012-02-09 17:45:34.065 MyApp[7147:707] User Cancelled Transaction
    2012-02-09 17:45:58:174 MyApp[7147:20747] …
Run Code Online (Sandbox Code Playgroud)

objective-c in-app-purchase mkstorekit

0
推荐指数
1
解决办法
2502
查看次数