小编Pet*_*ete的帖子

UIButton自定义字体垂直对齐

我有一个UIButton使用自定义字体,在我的视图加载时设置:

- (void)viewDidLoad
{
    [super viewDidLoad];    
    self.searchButton.titleLabel.font = [UIFont fontWithName: @"FONTNAME" size: 15.0 ];
}
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是字体似乎浮出中心线.如果我注释掉这一行,默认字体会垂直居中显示.但是更改为自定义字体会破坏垂直对齐.

我也在使用自定义字体的Table Cell上遇到了同样的问题.

我是否需要告诉视图某处自定义字体不像其他字体那么高?

编辑:我刚刚意识到我使用的字体是Windows TrueType字体.我可以在Mac上的TextEdit中使用它,只是我的应用程序中的对齐问题

按钮文本不是垂直居中

fonts objective-c vertical-alignment ios

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

AngularJS多次使用Controller和rootScope

我想在2个单独的HTML元素上使用控制器,并使用$ rootScope在编辑一个时保持2个列表同步:

HTML

<ul class="nav" ng-controller="Menu">
    <li ng-repeat="item in menu">
        <a href="{{item.href}}">{{item.title}}</a>
    </li>
</ul>

<div ng-controller="Menu">
    <input type="text" id="newItem" value="" />
    <input type="submit" ng-click="addItem()" />
    <ul class="nav" ng-controller="Menu">
        <li ng-repeat="item in menu">
            <a href="{{item.href}}">{{item.title}}</a>
        </li>
    </ul>    
</div>
Run Code Online (Sandbox Code Playgroud)

JS

angular.module('menuApp', ['menuServices']).
    run(function($rootScope){
        $rootScope.menu = [];
    });

angular.module('menuServices', ['ngResource']).
    factory('MenuData', function ($resource) {
        return $resource(
            '/tool/menu.cfc', 
            {
                returnFormat: 'json'
            },
            {
                getMenu: {
                    method: 'GET',
                    params: {method: 'getMenu'}
                },
                addItem: {
                    method: 'GET',
                    params: {method: 'addItem'}
                }
            }
        );
    });

function Menu($scope, …
Run Code Online (Sandbox Code Playgroud)

javascript data-binding controller angularjs

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

AngularJS服务http成功函数使用错误的"this"范围

a的成功函数$http.put无法访问this其内部调用的服务范围.我需要在PUT请求的回调中更新服务的属性.

这是我在服务中尝试做的一个简要示例:

var myApp = angular.module('myApp', function($routeProvider) {
// route provider stuff
}).service('CatalogueService', function($rootScope, $http) {
    // create an array as part of my catalogue
    this.items = [];

    // make a call to get some data for the catalogue
    this.add = function(id) {
        $http.put(
            $rootScope.apiURL,
            {id:id}
        ).success(function(data,status,headers,config) {
             // on success push the data to the catalogue
             // when I try to access "this" - it treats it as the window
             this.items.push(data);
        }).success(function(data,status,headers,config) {
            alert(data);
        }); …
Run Code Online (Sandbox Code Playgroud)

service http angularjs

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

如何在Cordova/Phonegap Android应用程序中使用Parse.com推送通知?

如何使用Parse.com将推送通知发送到我的Cordova 3.5.0 Android应用程序.

大多数帖子似乎涵盖了我的问题的某些方面,但不是全范围(Parse/Android或Phonegap/Parse)

我实际上已经解决了这个问题,但我在这里提出了完整的解决方案,因为我必须使用各种支离破碎的解决方案和论坛才能找到答案,而且我认为Cordova/Phonegap和Parse的组合越来越受欢迎,而且似乎成为很多有类似问题的人.

java eclipse android cordova parse-platform

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

Smarty PHP与AngularJS发生冲突

当我在同一模板中使用AngularJS时,如何阻止Smarty抛出错误.我有一个包含此代码的Smarty页面模板:

 <li ng-repeat="i in items">
      <p class="item">{{i}}</p>
 </li>
Run Code Online (Sandbox Code Playgroud)

当我在浏览器中查看时,我得到一个空白页面.我的apache error_log中出现了一个很大的错误,其中包含以下内容:

 PHP Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template ... <p>{{i}}</p>; unknown tag "i
Run Code Online (Sandbox Code Playgroud)

如果我将{{i}}替换为{{4}}或任何其他数字,则可以正常工作.我也可以使用数学,{{8 + 2}}将在页面中显示10.这是Smarty做angularJS的数学吗?

javascript php template-engine smarty angularjs

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

AngularJS子目录路由不起作用,应用了<base>标记

我有一个非常简单的AngularJS模板,我正在尝试让路由工作,但是当我加载页面时,我只是看到了我的H1标签index.html.

我的应用程序位于子目录中/angular-route/,并且我知道部分存在,我可以访问/angular-route/partials/interest.html并且页面呈现正常.

我错过了一些非常基本的东西吗?

<html>
<head ng-app="myApp">
    <title>AngularJS Routing</title>
    <base href="/angular-route/" />
</head>
<body>

<h1>AngularJS Routing</h1>

<div ng-view></div>

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>

<script>
    'use strict';

    var myApp = angular.module('myApp', []).
      config(['$routeProvider', function($routeProvider) {
        $routeProvider.
            when('/interest', {
                templateUrl: 'partials/interest.html',   
                controller: 'InterestCtrl'
            }).
            when('/catalogue', {
                templateUrl: 'partials/catalogue.html', 
                controller: 'CatalogueCtrl'
            }).
            otherwise({redirectTo: '/interest'});
    }]);

    myApp.controller('InterestCtrl', function($scope, $routeParams) {
        console.log('InterestCtrl');
    });
    myApp.controller('CatalogueCtrl', function($scope, $routeParams) {
        console.log('CatalogueCtrl');
    });
</script>
Run Code Online (Sandbox Code Playgroud)

routing angularjs

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

Amazon S3 SDK PHP doesObjectExist()问题

我已经重新编写了这个问题,以便更清楚,因为我已经更新了它.

我在使用Amazon AWS S3 PHP SDK时遇到问题.我只是想检查一个文件是否存在.使用这个PHP脚本:

<?php
    require_once("../../../configs/config.".get_current_user().".php");
    require INCLUDES_PATH . 'libraries/aws/aws-autoloader.php';

    use Aws\S3\S3Client;

    $client = S3Client::factory(array(
          'key' => AWS_ACCESS_KEY_ID,
          'secret' => AWS_SECRET_KEY
      ));

    $key = 'profile/avatar/80745d03-c295-4205-bd82-58161f2fd2d1-320.jpg';
    $result = $client->doesObjectExist( AWS_S3_BUCKET, $key );

    var_dump(AWS_S3_BUCKET);
    var_dump($key);
    var_dump($result);

?>
Run Code Online (Sandbox Code Playgroud)

这是输出:

string(19) "stage.socialite.app"
string(59) "profile/avatar/80745d03-c295-4205-bd82-58161f2fd2d1-320.jpg"
bool(false)
Run Code Online (Sandbox Code Playgroud)

我知道该文件存在,它在这里:

http://stage.socialite.app.s3.amazonaws.com/profile/avatar/80745d03-c295-4205-bd82-58161f2fd2d1-320.jpg

这是用户的IAM策略,其密钥ID和密钥我正在使用:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
          "s3:*"
      ],
      "Resource": [
        "arn:aws:s3:::stage.socialite.app/*",
        "arn:aws:s3:::stage.socialite.app"
      ]
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我刚刚创建了一个新的Key/Secret对并将它们添加到我的配置中 - 我做错了什么?

php amazon-s3 amazon-web-services

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

iOS Ad Hoc安装失败

当我尝试通过TestFlightApp.com安装应用程序时出现以下错误.

"Unable to download application. "helloworld" could not be installed at this time.
Run Code Online (Sandbox Code Playgroud)

我也试过通过iTunes和Apple Configurator进行安装.

当我第一次遇到这个错误时,我认为这可能是由于Apple的开发人员计划在几周之前停止了,所以我使用笔记本电脑上的代码签名请求重新生成了所有证书,然后重建了我的所有配置文件.

然后,我从我的iPhone和XCode中删除了所有配置文件,并从手机中删除了TestFlight.

然后,我将应用程序存档,上传到测试航班,授予配置文件中的所有设备,并通过下载链接发送通知电子邮件.

当我尝试下载时,进度条几乎一直到最后,然后弹出错误.这是我在安装过程中在控制台中看到的内容(来自iPhone配置实用程序):

SpringBoard[67] <Warning>: Killing com.helloworldapp for app installation
installd[53] <Error>: 0x2c6000 handle_install: Install 
    of "/var/mobile/Media/Downloads/-2429066128781955904/-410631401396950200" 
    requested by itunesstored
installd[53] <Error>: 0x2c6000 MobileInstallationInstall_Server: Installing 
    app com.helloworldapp
installd[53] <Error>: Aug 23 11:45:37  SecTrustEvaluate  
    [leaf CriticalExtensions IssuerCommonName]
installd[53] <Error>: 0x2c6000 verify_signer_identity: 
    MISValidateSignatureAndCopyInfo failed for
    /var/tmp/install_staging.a1ku9y/foo_extracted/Payload/helloworld.app/helloworld: 0xe8008017
installd[53] <Error>: 0x2c6000 do_preflight_verification: Could not verify 
    executable at /var/tmp/install_staging.a1ku9y/foo_extracted/Payload/helloworld.app
installd[53] <Error>: 0x2c6000 install_application: Could not preflight 
    application install …
Run Code Online (Sandbox Code Playgroud)

installation ad-hoc-distribution ios testflight

6
推荐指数
2
解决办法
7618
查看次数

Chrome DevTools框架事件计时

我正在使用Chrome来隔离应用动画中的瓶颈.

它显示帧大约需要20 + ms,这太慢了.但是当我对框架进行详细说明以查看发生了什么时,它会向我显示一个jQuery调用需要20 + ms,但实际的Recalculate Style事件只需要5ms.

我怎样才能找出导致这种延迟的原因?我看不出其他15ms是什么

总活动时间:

Chrome DevTools显示jQuery函数调用的总时间

jQuery函数中的"Recalculate Style"事件

Chrome DevTools显示重新计算样式事件的时间分割

在"重新计算风格"之前叠加

Chrome DevTools显示重新计算样式事件的堆栈

javascript performance jquery google-chrome frame-rate

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

我可以从抓取中恢复GIT藏匿

我有一个git repo,我的同事在他的电脑上克隆了它.无论出于何种原因,我们因技术问题而丢失了他的存储库.

在我们失去回购之前不久,他把一些工作藏起来了,然后我做了一个git fetch跟随git merge master.

是否有可能获得藏匿的内容?那git fetch命令也会把藏匿物拉过来吗?

我可以查看所有远程分支,git branch -a但我需要隐藏数据.

我们正在运行git version 1.6.3.3的Ubuntu 9.10 Karmic

linux git git-stash git-fetch

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