并提前感谢.
我正在寻找有关如何在我的应用程序中布局视图控制器的建议,我仍然有一个持久的背景和一些背景动画
这是它目前的设置方式:
在代码中:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIImageView* backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"underthesea.jpg"]] autorelease];
backgroundView.contentMode = UIViewContentModeScaleAspectFill;
backgroundView.frame = [UIScreen mainScreen].bounds;
self.viewController = [[[RootViewController alloc] init] autorelease];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.spriteLayer = [[[SpriteLayer alloc] initWithFrame:self.viewController.view.frame] autorelease];
self.viewController.spriteLayer = self.spriteLayer;
[window addSubview:backgroundView];
[window addSubview:self.spriteLayer];
[window addSubview:self.navigationController.view];
[window makeKeyAndVisible];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
`
Sprite Layer一直在后台可见,包含不同的动画.问题是,现在我正在尝试实现autorisizing并遇到困难,因为sprite层中的视图不在UIViewController中.
我认为一种可能性是使SpriteLayer子类为UIViewController,但不要将它放在导航控制器中; 它只会存在于导航控制器正在显示的任何视图后面.我不知道是否同时拥有2个视图控制器,这将是错误的来源或只是糟糕的设计,因为我已经在StackOverflow上读到这不是视图控制器的预期设计.
有什么意见吗?
干杯,里奇
PS我在代码块中放置一个客观的C方法时遇到问题.后面的勾号似乎不起作用,因为代码字体中唯一的代码部分是缩进的.有人知道这样做的正确方法吗?再次感谢.
我正在使用PHP开关根据页面URL参数中传入的传入关键字包含某些文件.
例如,URL可以是: ...page.php?kw=citroen%20berlingo%20keywords
在页面内部,我想使用这样的东西:
<?
switch($_GET['kw']){
case "berlingo":
include 'berlingo.php'
break;
case "c4":
include 'c4.php';
break;
}
?>
Run Code Online (Sandbox Code Playgroud)
我想在第一种情况下做的是包含berlingo.php文件,如果关键字参数包含 berlingo,但它不必仅仅是该关键字.
例如,我想包括的berlingo.php文件,如果关键字berlingo,但也如它的citroen berlingo.
如何使用PHP case select(switch语句)评估给定字符串是否包含值?
谢谢.
我有一个像这样的目录结构:
project
lib
paperboy
redis-client
node-cookie
srv
main.js
...
Run Code Online (Sandbox Code Playgroud)
我从项目目录启动main.js:
$ node srv/main.js
Run Code Online (Sandbox Code Playgroud)
在main.js中,我可以这样做:
paperboy = require('./lib/paperboy');
Run Code Online (Sandbox Code Playgroud)
但是,这失败了:
redis = require('./lib/redis-client');
Run Code Online (Sandbox Code Playgroud)
同样,如果我在"项目"目录中启动交互式节点,我可以要求使用paperboy,但不能使用redis-client.我得到的错误是:
> require('./lib/redis-client')
Error: Cannot find module './lib/redis-client'
at resolveModuleFilename (node.js:265:13)
at loadModule (node.js:231:20)
at require (node.js:291:14)
...
Run Code Online (Sandbox Code Playgroud)
查看resolveModuleFilename()的源代码,它会尝试打印调试字符串,我看不到:
debug("looking for " + JSON.stringify(id) + " in " + JSON.stringify(paths));
Run Code Online (Sandbox Code Playgroud)
我尝试通过导出NODE_DEBUG = 1来启用它,但在尝试要求时我仍然没有看到此调试打印.
在尝试打印这个调试时我做错了什么?第二,为什么paperboy加载得很好,但redis-client找不到?
附加信息:这是"lib"目录中的完整文件/目录列表:
lib
lib/cookie-node
lib/cookie-node/package.json
lib/cookie-node/LICENSE.txt
lib/cookie-node/README.markdown
lib/cookie-node/example
lib/cookie-node/example/ex1.js
lib/cookie-node/index.js
lib/redis-client
lib/redis-client/package.json
lib/redis-client/TODO.md
lib/redis-client/examples
lib/redis-client/examples/redis-version.js
lib/redis-client/examples/using-kiwi.js
lib/redis-client/examples/subscriber.js
lib/redis-client/examples/publisher.js
lib/redis-client/examples/.redis-version.js.swp
lib/redis-client/examples/README.md
lib/redis-client/seed.yml
lib/redis-client/LICENSE
lib/redis-client/test
lib/redis-client/test/test_throw_from_callback.js
lib/redis-client/test/test_shutdown_reconnect.js
lib/redis-client/test/test.js …Run Code Online (Sandbox Code Playgroud) 我想从这段代码中获取捕获等级:
$RankStr = 'var trafficstatsSnippet = "/site/trafficstats;pysa1bpbPOVl6Wm5d4Zv4nKXKdM%3D
/aahoonet.com/?adult=&category=&rank=1234567";'
Run Code Online (Sandbox Code Playgroud)
我用这个代码:
Run Code Online (Sandbox Code Playgroud)$NewPOS = strpos($RankStr, "rank="); $SRank = substr($RankStr, $NewPOS + 5, 10); echo $SRank;
因为RANK代码变量来自(1 - 25,000,000),我使用上面的代码,通过在rank = plus 5进一步索引的位置后选择最多10个charachters.
所以这个函数返回
1234567";
Run Code Online (Sandbox Code Playgroud)
然后我想从字符串中获取此数字.尝试preg_match_all或regex但由于不熟悉这些功能,我无法获得任何有用的响应.
请帮助我解决这个问题,如果有更多的解决方案请提供给他们!
现在我有两个哈希.我想将一个完整的哈希值分配给第二个哈希中的id.但是,我无法将该哈希值分配给另一个哈希.
您可以通过以下方式将哈希分配到另一个哈希:
$nodes{$id}=%nodeHash;
Run Code Online (Sandbox Code Playgroud)
现在这不起作用,因为当我说:
print Dumper(\%nodes);
Run Code Online (Sandbox Code Playgroud)
我得到了这个结果:
$VAR1 = {
'c2' => '4/8',
'c1' => {}
};
Run Code Online (Sandbox Code Playgroud)
对不起,如果这不是完全有意义的话,我不是一个非常有经验的程序员,所以哈希的散列非常复杂.
我正在寻找一个将多组整数映射到整数的函数,希望它具有成对独立性等某种保证.
理想情况下,内存使用量将保持不变,并且哈希值可以在插入/删除后的O(1)时间内更新.(这禁止执行诸如排序整数和使用哈希函数之类的操作,如h(x)= h_1(x_1,h_2(x_2,h_3(x_3,x_4))).)
XORing哈希值不起作用,因为h({1,1,2})= h({2})
我认为如果底层哈希函数具有不切实际的强保证(例如n独立性),则将模数乘以模数可能会起作用.
调用vector时我得到这个编译器错误size().为什么?
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cassert>
using namespace std;
class Vertex {
float firstValue;
float secondValue;
float thirdValue;
Vertex (float first, float second, float third){
firstValue=first;
secondValue=second;
thirdValue=third;
}
};
int main()
{
cout<<"This program loads a 3D .off object. \nEnter the name of the file that describes it "<<endl;
string inputFileName;
getline(cin, inputFileName);
ifstream inputFileStream;
inputFileStream.open(inputFileName.data());
assert (inputFileStream.is_open());
string actualLine;
for(;;){
inputFileStream>>actualLine;
istringstream actualLineStream(actualLine);
std::vector<float> results( std::istream_iterator<int>(actualLineStream)
, std::istream_iterator<int>() ); …Run Code Online (Sandbox Code Playgroud) 我从业务层返回IList.但在viewmodel中我必须使用Find函数.一种方法是将IList转换为List.
但无论如何都要向IList添加"查找"方法
我必须将非托管的dll导入我的C#应用程序,我想知道IntPtr和ref之间有什么不同,你建议我使用什么,为什么?请注意,这两种方式对我都有用.例如:
[DllImport("mydll.dll", CallingConvention=CallingConvention.Cdecl)]
static extern Result Init(IntPtr versionInfo);
[DllImport("mydll.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern Result Init(ref Version versionInfo);
Run Code Online (Sandbox Code Playgroud) 我正在从Authlogic迁移到Devise.
更新:
设计的迁移尝试重新创建表用户,所以我改变了,你可以在下面看到create_table到change_table并删除表的末尾以删除我添加的内容
问题是当我运行rake时我得到一个错误.
这是我在运行rake时遇到的错误.
== DeviseCreateUsers: migrating ==============================================
-- change_table(:users)
rake aborted!
An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "email" varchar(255) DEFAULT '' NOT NULL
Run Code Online (Sandbox Code Playgroud)
这是迁移
class DeviseCreateUsers < ActiveRecord::Migration
def self.up
change_table(:users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token_authenticatable
t.timestamps
end
add_index :users, :email, :unique => true
add_index :users, :reset_password_token, :unique => …Run Code Online (Sandbox Code Playgroud)