问题列表 - 第37569页

如何使UIImageView变暗

我需要在触摸时使UIImageView变暗,几乎就像跳板(主屏幕)上的图标一样.

我是否应该添加0.5 alpha和黑色背景的UIView.这看起来很笨拙.我应该使用图层还是其他东西(CALayers).

iphone objective-c layer uiimageview

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

MooTools的Function.prototype.overloadSetter()有什么作用?

我正在浏览MooTools源代码,试图了解它.implement().extend()实用程序.

每个的定义指的是这样定义的函数:

var enumerables = true;
for (var i in {toString: 1}) enumerables = null;
if (enumerables) enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'constructor'];

Function.prototype.overloadSetter = function(usePlural){
    var self = this;
    return function(a, b){
        if (a == null) return this;
        if (usePlural || typeof a != 'string'){
            for (var k in a) self.call(this, k, a[k]);
            if (enumerables) for (var i = enumerables.length; i--;){
                k = enumerables[i];
                if (a.hasOwnProperty(k)) self.call(this, k, a[k]);
            }
        } else …
Run Code Online (Sandbox Code Playgroud)

javascript mootools

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

如何在两个类中使用相同的变量

# I have this class:

class Test(webapp.RequestHandler):
    myList = []
    def get(self):
        s = [self.request.get('sentence')]
        self.myList.append(s)
        htmlcode1 = HTML.table(self.myList)
        myListLen = len(self.myList)
        lastItem = self.myList[myListLen-2]

# I want to add the following to delete the contents of `myList` when I enter 'delete' in the form:

class Delete(webapp.RequestHandler):
    def get(self):
        if s == ['delete']:
            del self.myList[:]
Run Code Online (Sandbox Code Playgroud)

我怎么用self.myListDelete()

python

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

使用带有AJAX和jQuery的HTML5文件上传

不可否认,Stack Overflow上存在类似的问题,但似乎没有完全符合我的要求.

以下是我要做的事情:

  • 上传整个数据形式,其中一个是单个文件
  • 使用Codeigniter的文件上传库

直到这里,一切都很好.数据在我需要时进入我的数据库.但我也想通过AJAX帖子提交我的表格:

  • 使用原生HTML5文件API,而不是Flash或iframe解决方案
  • 优选地与低级.ajax()jQuery方法接口

我想我可以想象如何通过使用纯javascript在字段的值更改时自动上传文件来实现此目的,但我宁愿一下子在jQuery中提交所有内容.我认为通过查询字符串是不可能的,因为我需要传递整个文件对象,但我现在有点迷失在这一点上做什么.

这可以实现吗?

javascript ajax jquery html5 file-upload

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

CountDownTimer:“无法在未调用 Looper.prepare() 的线程内创建处理程序”

我知道之前已经问过“无法在没有调用 Looper.prepare() 的线程内创建处理程序”的一般问题,但我很难理解它在这种情况下如何应用。

我正在尝试在非 UI 线程中构造一个新的 CountDownTimer,我猜这是导致此错误的原因,但我真的不明白为什么需要在主线程中使用计时器。从我所见,它似乎有一个回调处理程序,需要在具有循环程序的线程中运行,非 UI 线程默认情况下没有。看来我的选择是:1)让这个非 UI 线程有一个 Looper 或 2)在我的 UI 线程上做一些奇怪的方法来构造这个计时器,这两种方法对我来说都很愚蠢。有人可以帮助我理解其中的含义吗?

另外,有没有人知道任何有用的链接可以阐明 Looper 和 MessageQueue?我没有很好地掌握它们,正如我确信我已经展示的那样。谢谢!

multithreading android looper countdowntimer

5
推荐指数
2
解决办法
5486
查看次数

const限定符的问题是获取对象的私有属性

我是一个全新的C++,我有一个非常愚蠢的问题.

我有一个Graph类,我需要为它创建一个复制构造函数.这是我的班级:

#include <igraph.h>
#include <iostream>
using namespace std;


class Graph { 
public:
  Graph(int N); // contructor
  ~Graph();     // destructor
  Graph(const Graph& other); // Copy constructor 
  igraph_t * getGraph();
  int getSize();

private:
  igraph_t graph;
  int size;
};
Run Code Online (Sandbox Code Playgroud)

有一个功能int igraph_copy(igraph_t * to, const igraph_t * from),igraph.h可以igraph_t充分复制一种类型.

构造函数和析构函数是微不足道的,并且工作正常,我有以下复制构造函数:

Graph :: Graph(const Graph& other) {
  igraph_t * otherGraph = other.getGraph();
  igraph_copy(&graph, otherGraph);
  size = other.getSize();

}

igraph_t * Graph :: getGraph(){ 
  return &graph;
}

int Graph :: …
Run Code Online (Sandbox Code Playgroud)

c++ constructor const copy-constructor

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

不能使用django的render_to_string对单引号(&#39;)进行编码

我有一个django的render_to_string和编码单引号的问题.

... = render_to_string('dummy.txt', {'request':request, 'text':text,}, context_instance=RequestContext(request)))
Run Code Online (Sandbox Code Playgroud)

为什么只有这些引号翻译成'#39;' 和所有其他特殊字符不?

django unicode quotes render-to-string

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

Rails - 使用thin时的bundler错误

我开始使用bundler并且在使用它时遇到一些问题.我有以下gemfile:

source "http://rubygems.org"
gem "rack", "~>1.1"
gem 'pg','>= 0.8.0'
gem 'rails','2.3.8'
gem 'authlogic','2.1.3'
gem 'ajaxful_rating','2.2.3'
gem 'will_paginate','2.3.12'
gem 'right_aws','1.10.0'
gem 'aws-s3','0.6.2'
gem 'declarative_authorization','0.4.1'
gem 'timeline_fu','0.3.0'
gem 'friendly_id','>= 3.1'
Run Code Online (Sandbox Code Playgroud)

请注意,我具体说我想使用rack 1.1(1.1.0).

我运行瘦时遇到以下错误(Webrick工作正常):

thin start
>> Using rails adapter
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/runtime.rb:27:in `setup': You have already activated rack 1.2.1, but your Gemfile requires rack 1.1.0. Consider using bundle exec. (Gem::LoadError)
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/runtime.rb:17:in `setup'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler.rb:100:in `setup'
 from /home/vmplanet/Documents/maga/config/../config/preinitializer.rb:16
 from /home/vmplanet/Documents/maga/config/boot.rb:28:in `load'
 from /home/vmplanet/Documents/maga/config/boot.rb:28:in `preinitialize'
 from /home/vmplanet/Documents/maga/config/boot.rb:10:in `boot!'
 from …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails thin bundler

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

如何构建通用的ios静态库

我正在尝试构建一个可以与ios3.x和ios4.x一起使用的静态库.我可以使用ios3.0构建一个静态库,它可以在ios3.0中与另一个项目一起使用,但不能在ios4中编译.从ios4到ios3也是如此.

以下是重新创建的方法:

  1. 打开XCode 3.2.4并启动一个名为Library4的Cocoa Touch静态库的新项目
  2. 单击classes文件夹并创建一个名为"TestViewController"的新UIViewController
  3. 右键单击Frameworks文件夹,添加现有框架,选择UIKit
  4. 在左侧面板中,展开目标,右键单击我的库目标,然后单击获取信息.更改为所有配置,将基本sdk更改为iphone模拟器4.0,将ios部署目标更改为ios3.0
  5. 单击带有二进制文件的链接库文件夹.在右侧窗格中,将两者的角色更改为"Weak"
  6. 建立图书馆
  7. 打开Xcode 3.2.2并启动一个名为Library4Test的基于View的新应用程序
  8. 将TestViewController.h复制到classes文件夹
  9. 将libLibrary4.a文件复制到frameworks文件夹.它会自动添加到目标的链接器阶段
  10. 右键单击Library4Test Target并单击获取信息.在其他链接器标志中,添加"-ObjC"和"-all_load"
  11. 在app delegate header中添加Import"TestViewController.h"
  12. 在app delegate header的应用程序的didFinishLaunchingWithOptions方法中添加

    TestViewController*test = [TestViewController alloc] init;

  13. 使用ios3.0模拟器进行编译

当我编译时,我得到:

Ld build/Debug-iphonesimulator/library4Test.app/library4Test normal i386
cd /Users/test/Documents/Testing/library4Test
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/GrandpaIPhone/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/GrandpaIPhone/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/GrandpaIPhone/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/GrandpaIPhone/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk -L/Users/test/Documents/Testing/library4Test/build/Debug-iphonesimulator -L/Users/test/Documents/Testing/library4Test -F/Users/test/Documents/Testing/library4Test/build/Debug-iphonesimulator -filelist /Users/test/Documents/Testing/library4Test/build/library4Test.build/Debug-iphonesimulator/library4Test.build/Objects-normal/i386/library4Test.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -llibrary4_1 -o /Users/test/Documents/Testing/library4Test/build/Debug-iphonesimulator/library4Test.app/library4Test

Undefined symbols:
"_objc_msgSendSuper2", referenced from:
-TestViewController didReceiveMemoryWarning in liblibrary4_1.a(TestViewController.o)
-TestViewController viewDidUnload in liblibrary4_1.a(TestViewController.o)
-TestViewController dealloc in liblibrary4_1.a(TestViewController.o)
"__objc_empty_vtable", referenced …
Run Code Online (Sandbox Code Playgroud)

iphone xcode static-libraries universal-binary ios

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

根据开发人员用CSS指定的内容,是否可以使用jQuery以百分比或像素为单位获取元素的宽度?

我正在编写一个jQuery插件,我需要做的是确定用户指定的元素的宽度.问题是.width()或.css('width')将始终报告精确的像素,即使开发人员已经使用CSS分配了宽度:90%.

有没有办法让jQuery输出px或%中元素的宽度,具体取决于开发人员用CSS给出的内容?

css jquery width

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