小编fia*_*lli的帖子

instantiateViewControllerWithIdentifier,但xCode 4.5中的标识符在哪里?

我有一个带书名的UITableView.我还有一个视图(AddAndEditBookViewController)来输入有关书籍的信息.当我点击表格导航栏上的"+"时,我想打开我的AddAndEditBookViewController.如果我在一个单独的nib文件中创建表,我知道如何做到这一点,但是如果我的视图是在storyboard中创建的,我该怎么做呢(没有segues ...此时更多用于学习目的).

我读到我可以使用故事板中的instantiateViewControllerWithIdentifier方法,但是如何找到视图控制器的id?我试着查看故事板的XML表示,但我似乎没有找到它......

这是尝试打开模态视图的代码.

- (void)insertNewObject:(id)sender
{
    AddAndEditBooksViewController * addViewController = (AddAndEditBooksViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"gH8-2m-MXv"];
    [addViewController setDelegate:self];
    [addViewController setModalPresentationStyle:UIModalPresentationFormSheet];
    [self presentViewController:addViewController animated:YES completion:NULL];
}
Run Code Online (Sandbox Code Playgroud)

我的具体问题是:我应该使用什么标识符?在哪里指定或如何手动指定它?

谢谢!

ios xcode4.5

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

Java中的可序列化,可复制和内存使用

我正在使用一个内部类,它是HashMap的子类.我有一个String关键和double[]价值观.我每次存储约200个双打double[].我应该使用大约700 MB来存储密钥,指针和双打.然而,内存分析显示我需要更多(略多于2 GB).

使用TIJmp(分析工具)我看到有一个char[]使用了几乎一半的总内存.TIJmp表示char[]来自SerializableCloneable.其中的值范围从字体列表和消息和单个字符的默认路径.

SerializableJVM中的确切行为是什么?它是否始终保持"持久"副本,从而使我的内存占用量增加一倍?如何在运行时编写对象的二进制副本而无需将JVM转换为内存占用?

PS:内存消耗增加最多的方法是下面的方法.该文件每行大约有229,000行和202个字段.

public void readThetas(String filename) throws Exception
{
    long t1 = System.currentTimeMillis();
    documents = new HashMapX<String,double[]>(); //Document names to indices.
    Scanner s = new Scanner(new File(filename));
    int docIndex = 0;
    if (s.hasNextLine())
        System.out.println(s.nextLine()); // Consume useless first line :)
    while(s.hasNextLine())
    {
        String[] fields = s.nextLine().split("\\s+");
        String docName = fields[1];
        numTopics = fields.length/2-1;
        double[] thetas = new double[numTopics];
        for …
Run Code Online (Sandbox Code Playgroud)

java memory heap serializable cloneable

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

Weka CSVLoader错误的值数.阅读2,预计23

我正在尝试使用来自GUI的Weka的CSVLoader将CSV转换为ARFF.在选项中,我为字符串设置了外壳字符",尽管我的文件中没有引号.我收到以下错误:

weka.core.converters.CSVLoaderfailed to lead <my file>
Reason:
wrong number of values. Read 2, expected 23, read Token[EOL], line 1763
Run Code Online (Sandbox Code Playgroud)

这是第1762-1764行:

450c787001b004af69428e267c7a4ca1,I_need need_to to_go go_back back_to to_my my_live live_food food_diet diet_PPP PPP_Not Not_90% 90%_like like_before before_CCC CCC_but but_I I_bet bet_I I_could could_do do_75% 75%_without without_losing losing_too too_much much_weight weight_PPP PPP_PPP,2.30,3.50,4.50,2.85,4.50,n,y,y,n,y,AM,297,41728.8,95.58,0.03,42826,0.49,0.17,-12.5611111111,0.248945147679,0.0595238095238
450c787001b004af69428e267c7a4ca1,It's_ugly ugly_here here_PPP PPP_But But_there there_are are_sparks sparks_PPP PPP_PPP PPP_PPPmoments PPPmoments_PPP PPP_Love Love_PPP,2.30,3.50,4.50,2.85,4.50,n,y,y,n,y,AM,297,41728.8,95.58,0.03,42826,0.49,0.17,-15.91,0.299242424242,0.1
450c787001b004af69428e267c7a4ca1,I_guess guess_it it_all all_depends depends_on on_your your_mood mood_PPP PPP_PPP PPP_PPPwhy PPPwhy_can't can't_these these_meds meds_be be_any any_damn …
Run Code Online (Sandbox Code Playgroud)

weka

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

语法高亮显示Reveal.js中的代码如何?

我克隆了reveal.js的git repo,将js,css,pluginlib目录复制到/ my-home-dir /并创建了一个名为的示例页面r.html.

r.html我有一个<pre><code></code></pre>块,但它没有突出显示...这是我理解的默认行为.我继续并改变了reveal.js的初始化以帮助解决这个问题,但没有任何改变.(主题和幻灯片都没问题)

有什么建议?

代码r.html如下:

<!doctype html>
<html lang="en">    
<head>
    <meta charset="utf-8">
    <title>Reveal.js 3 Slide Demo</title>
    <link rel="stylesheet" href="css/reveal.min.css">
    <link rel="stylesheet" href="css/theme/default.css" id="theme"> 
    <!--Add support for earlier versions of Internet Explorer -->
    <!--[if lt IE 9]>
    <script src="lib/js/html5shiv.js"></script>
    <![endif]-->
</head>

<body>
    <!-- Wrap the entire slide show in a div using the "reveal" class. -->
    <div class="reveal">
        <!-- Wrap all …
Run Code Online (Sandbox Code Playgroud)

javascript syntax-highlighting reveal.js

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

未捕获的ReferenceError :(函数)未定义

我只是认为这对有此问题的人很有用:

我有以下代码:

<html>
<head>
    <link rel="stylesheet" href="example.css" type="text/css"/>
    <title>CSS TESTS</title>
    <script language="text/javascript">
        var move = 0;
    </script>
</head>
<body>
    <input type="text" id="shape" onchange="alert(move);"/>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

但是我无法获得警报的效果。我会得到Uncaught ReferenceError:未定义移动。

javascript

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

元组作为字典的关键词:'tuple'对象不支持项目分配

我在python中有这个功能:

def initialize(s,cfg):
    pi={},
    for i,w in enumerate(s):
        j=i+1
        for X,rhs in cfg.items():
            if rhs.has_key(w):
                print (j,j,X),rhs[w]
                pi[(j,j,X)]=rhs[w]
    return pi
Run Code Online (Sandbox Code Playgroud)

当我跑去的时候

    pi[(j,j,X)]=rhs[w]
TypeError: 'tuple' object does not support item assignment
Run Code Online (Sandbox Code Playgroud)

它上面的印刷品返回 (1, 1, 'DT') 1.0

我必须遗漏一些东西,但据我所知,我并不想改变元组.为什么我会收到这个错误?

有一次我认为这可能是由于j和X被指向并试图创建一个新的元组,但这不起作用.我也在shell上试过这个:

>>> pi={}
>>> X="DT"
>>> j=1
>>> t=(j,j,X)
>>> pi[t]=1.0
>>> pi
{(1, 1, 'DT'): 1.0}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,一切正常.关于我为什么要tuple does not support item assignment error进入我的函数而不是shell的任何想法?

python dictionary tuples

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