问题列表 - 第39091页

保持视图在导航控制器中的所有视图后面持久化的最佳方法

并提前感谢.

我正在寻找有关如何在我的应用程序中布局视图控制器的建议,我仍然有一个持久的背景和一些背景动画

这是它目前的设置方式:

  • AppDelegate创建一个导航控制器,RootViewController和一个Sprite Layer(它是UIView的子类)
  • AppDelegate还将背景图像保存为backgroundColor属性
  • 正常情况下,使用根视图控制器初始化导航控制器
  • rootview控制器将不同的表视图推送到导航堆栈

在代码中:

- (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方法时遇到问题.后面的勾号似乎不起作用,因为代码字体中唯一的代码部分是缩进的.有人知道这样做的正确方法吗?再次感谢.

iphone background uinavigationcontroller

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

如何使用PHP switch语句检查字符串是否包含单词(但也可以包含其他单词)?

我正在使用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语句)评估给定字符串是否包含值?

谢谢.

php string switch-statement url-parameters php-include

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

node.js:为什么NODE_DEBUG = 1不起作用?(尝试调试require()错误)

我有一个像这样的目录结构:

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)

v8 require redis node.js

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

一个简单的函数,用于从php中的字符串返回数字

我想从这段代码中获取捕获等级:

 $RankStr = 'var trafficstatsSnippet =  "/site/trafficstats;pysa1bpbPOVl6Wm5d4Zv4nKXKdM%3D
 /aahoonet.com/?adult=&category=&rank=1234567";'
Run Code Online (Sandbox Code Playgroud)

我用这个代码:

$NewPOS = strpos($RankStr, "rank=");
$SRank = substr($RankStr, $NewPOS + 5, 10);
echo $SRank;
Run Code Online (Sandbox Code Playgroud)

因为RANK代码变量来自(1 - 25,000,000),我使用上面的代码,通过在rank = plus 5进一步索引的位置后选择最多10个charachters.

所以这个函数返回

1234567"; 
Run Code Online (Sandbox Code Playgroud)

然后我想从字符串中获取此数字.尝试preg_match_allregex但由于不熟悉这些功能,我无法获得任何有用的响应.

请帮助我解决这个问题,如果有更多的解决方案请提供给他们!

php regex string numbers preg-match

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

将哈希值分配给哈希

现在我有两个哈希.我想将一个完整的哈希值分配给第二个哈希中的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)

对不起,如果这不是完全有意义的话,我不是一个非常有经验的程序员,所以哈希的散列非常复杂.

perl hash

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

对于整数的集合(即多集),什么是好的散列函数?

我正在寻找一个将多组整数映射到整数的函数,希望它具有成对独立性等某种保证.

理想情况下,内存使用量将保持不变,并且哈希值可以在插入/删除后的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独立性),则将模数乘以模数可能会起作用.

algorithm hash

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

错误C2228:'.size'的左边必须有class/struct/union

调用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)

c++ visual-studio-2008

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

如何向IList添加"查找"功能

我从业务层返回IList.但在viewmodel中我必须使用Find函数.一种方法是将IList转换为List.

但无论如何都要向IList添加"查找"方法

c# ilist list find

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

IntPtr vs ref C#

我必须将非托管的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)

c#

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

在现有模型上设计迁移

我正在从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)

ruby-on-rails

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