小编bob*_*obo的帖子

在iPhone应用程序中使用Localizable.strings

我下载了three20库:

http://three20.info/

我打开了这个库附带的TTCatalog示例项目:

http://img16.imageshack.us/img16/3183/screenshot20100302at752.png

如您所见,有很多Localizable.strings文件.

当我打开iPhone模拟器并在设置中将其语言更改为例如法语时,按钮上的文本仍保留为英语:

http://img69.imageshack.us/img69/9775/screenshot20100302at812.png

我已经检查过法语的Localization.strings中的文本"See All"肯定有相应的条目.

为什么以及使用Localizable.strings文件的步骤是什么?

(此示例项目未附带任何nib/xib文件)

编辑:

在Info.plist中添加以下XML后:

...
<dict>
...
    <key>CFBundleLocalizations</key>
    <array>
    <string>de</string>
    <string>en</string>
    <string>es</string>
    <string>fr</string>
    <string>it</string>
    <string>ja</string>
    <string>zh_cn</string>
    <string>zh_tw</string>  
    </array>
</dict>
...
Run Code Online (Sandbox Code Playgroud)

它现在有效!

iphone xcode localization three20

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

为什么我们应该让帐户激活/密码重置链接在一段时间后过期?

如果它们永不过期,会有任何重大问题吗?

有人忘了他的密码并要求重置他的密码,一封带有密码重置链接的电子邮件发送给他.

然后他突然想起了他的密码,所以他只是忽略了密码重置电子邮件.但过了几天,他又忘了.由于他的邮箱中已经有密码重置电子邮件,他只需点击该链接即可返回网站重置密码.

这似乎没问题,为什么我们应该让帐户激活/密码重置链接在一段时间后过期?

account activation forgot-password

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

C++中int x = 1和int x(1)有什么区别?

可能重复:
复制初始化和赋值初始化之间的C++是否存在差异?

我是C++的新手,我很少看到有人使用这种语法来声明和初始化变量:

int x(1);
Run Code Online (Sandbox Code Playgroud)

我试过,编译器没有抱怨,输出和int x = 1相同,它们实际上是一样的吗?

非常感谢大家.

c++ variables declaration

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

NSDictionary可以在iPhone上与TableView一起使用吗?

在UITableViewController子类中,为了加载数据和处理行选择事件,需要实现一些方法:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1; //there is only one section needed for my table view
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {              
    return [myList count]; //myList is a NSDictionary already populated in viewDidLoad method
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease ];
    }

    // indexPath.row returns an integer index, 
    // but myList uses keys that are …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c nsdictionary uitableview

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

我应该在没有h1的情况下使用多个h1或多个h2吗?

在显示教师列表的网页中,显示当前的HTML代码:

<div id="tutors">

 <h1>Tutors</h1>
 <div class="tutor">
  <h2>John</h2>
  <p>...</p>
 </div>

 <div class="tutor">
  <h2>Mary</h2>
  <p>...</p>
 </div>

 <div class="tutor">
  <h2>David</h2>
  <p>...</p>
 </div>

</div>
Run Code Online (Sandbox Code Playgroud)

现在,出于某些原因,需要在页面中删除当前由h1包装的单词Tutors.我可以想到3个选择:

  1. 使用css隐藏它.
  2. 只需删除它,页面将有h2没有h1.
  3. 将其删除,并将所有h2更改为h1.

哪一个更合适?

html seo html-heading

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

是否可以在ECB模式下使用带有IV的AES?

http://php.net/manual/en/function.mcrypt-encrypt.php,我看到以下代码使用AES和ECB模式下的IV,

<?php
    $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
    $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    $key = "This is a very secret key";
    $text = "Meet me at 11 o'clock behind the monument.";
    echo strlen($text) . "\n";

    $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv);
    echo strlen($crypttext) . "\n";
?>
Run Code Online (Sandbox Code Playgroud)

但是从维基http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation,它说欧洲央行不需要IV.是否真的可以在ECB模式下使用带有IV的AES?在这种ECB模式下,与不使用时相比,额外的IV是否会提供更多的安全性?

php encryption cryptography

4
推荐指数
3
解决办法
9881
查看次数

使用file_get_contents将本地PHP文件的HTML输出存储到字符串中

有一个header.php文件,它包含一些返回HTML的PHP​​代码.我知道我可以使用require,include来回显结果,但我想要做的是将处理后的输出字符串存储到变量中.

在一个页面中,我使用了:

$headerHTML=file_get_contents('header.php');
Run Code Online (Sandbox Code Playgroud)

然后我得到了PHP代码输出而不是处理过的HTML输出.我知道添加http://会有所帮助.但我更喜欢继续使用相对路径,我怎么能告诉函数正确处理php文件?

注意:我想继续使用此声明,file_get_contents而不是ob_start()尽可能使用.

php file-get-contents

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

我们如何匹配任何单个字符,包括Perl正则表达式中的换行符?

我想使用UltraEdit正则表达式(perl)将以下文本替换为一堆html文件中的其他文本:

<style type="text/css">

#some-id{}

.some-class{}

//many other css styles follow

</style>
Run Code Online (Sandbox Code Playgroud)

我尝试使用<style type="text/css">.*</style>但当然它不匹配任何东西,因为点匹配除换行之外的任何字符.我想匹配换行符,换行也许\r\n或者\n.

正则表达式应该如何?

非常感谢大家.

regex text pcre ultraedit

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

当我的应用程序在[NSUserDefaults standardUserDefaults]中保存数据时,是否会与其他应用程序发生冲突?

阅读此线程后: NSUserDefaults在模拟器上首次运行时不存在

我知道在[NSUserDefaults standardUserDefaults]中存储一些应用程序数据非常容易.但是,如果其他应用程序也碰巧使用相同的密钥来存储他们的数据,那么我的应用程序数据是否可能被覆盖?

非常感谢大家.

iphone nsuserdefaults

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

使用PHP提取HTML文档的正文文本

我知道为此目的使用DOM会更好,但让我们尝试以这种方式提取文本:

<?php


$html=<<<EOD
<html>
<head>
</head>
<body>
<p>Some text</p>
</body>
</html>
EOD;


        preg_match('/<body.*?>/', $html, $matches, PREG_OFFSET_CAPTURE);

        if (empty($matches))
            exit;

        $matched_body_start_tag = $matches[0][0];
        $index_of_body_start_tag = $matches[0][1];

        $index_of_body_end_tag = strpos($html, '</body>');


        $body = substr(
                        $html,
                        $index_of_body_start_tag + strlen($matched_body_start_tag),
                        $index_of_body_end_tag - $index_of_body_start_tag + strlen($matched_body_start_tag)
        );

echo $body;
Run Code Online (Sandbox Code Playgroud)

结果可以在这里看到:http://ideone.com/vH2FZ

如您所见,我收到的文字多于预期.

有一些我不明白的东西,为了获得substr($string, $start, $length)函数的正确长度,我正在使用:

$index_of_body_end_tag - $index_of_body_start_tag + strlen($matched_body_start_tag)
Run Code Online (Sandbox Code Playgroud)

我没有看到这个公式有什么问题.

有人可以建议问题出在哪里吗?

非常感谢大家.

编辑:

非常感谢你们所有人.我脑子里只有一个小虫.在阅读完答案后,我现在明白了问题所在,它应该是:

  $index_of_body_end_tag - ($index_of_body_start_tag + strlen($matched_body_start_tag));
Run Code Online (Sandbox Code Playgroud)

要么:

  $index_of_body_end_tag - $index_of_body_start_tag - strlen($matched_body_start_tag);
Run Code Online (Sandbox Code Playgroud)

php regex text text-processing html-content-extraction

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