小编Aar*_*own的帖子

为什么我的UITableView无法滚动,除非我告诉它为滚动设置动画?

我已经设置了一个表视图,以便在视图控制器加载时滚动到某一行.我将此代码放入viewDidLoad方法,它的工作方式与我的预期相符:

[thisTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:16 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];

但是,如果我将最后一位更改为animated:NO,则根本不会滚动.我很喜欢它的动画,但我想知道:如果动画设置为NO,为什么不滚动?

iphone objective-c uitableview ios

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

为什么re.findall()给我的结果与Python中的re.finditer()不同?

我写了这个正则表达式:

p = re.compile(r'''
\[\[            #the first [[
[^:]*?          #no :s are allowed
.*?             #a bunch of chars
(
\|              #either go until a |
|\]\]           #or the last ]]
)
                ''', re.VERBOSE)
Run Code Online (Sandbox Code Playgroud)

我想用来re.findall获取某些字符串的所有匹配部分.我写了一些测试代码,但它给了我奇怪的结果.

这段代码

g = p.finditer('   [[Imae|Lol]]     [[sdfef]]')
print g
for elem in g:
    print elem.span()
    print elem.group()
Run Code Online (Sandbox Code Playgroud)

给我这个输出:

(3, 10)
[[Imae|
(20, 29)
[[sdfef]] 
Run Code Online (Sandbox Code Playgroud)

做得很完美吗?但是当我这样做时:

h = p.findall('   [[Imae|Lol]]     [[sdfef]]')
for elem in h:
    print elem
Run Code Online (Sandbox Code Playgroud)

输出是这样的:

|
]]  
Run Code Online (Sandbox Code Playgroud)

为什么findall()打印出与finditer相同的结果?

python regex

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

我试图遍历Hashmap <LinkedList <String>,int [] >>.有没有比我正在做的更简单的方法呢?

对于一个项目,我必须创建一个键是Lists的映射,String值是两个整数.所以,我这样做了:

private Map<LinkedList<String>, int[]> playerProfile;
private List<String> previousChoices;
Run Code Online (Sandbox Code Playgroud)

然后我必须遍历地图并将所有键值组合写入数据文件.所以我正在设置一个像这样的迭代器:

    Set<Entry<LinkedList<String>, int[]>> profileSet;
    profileSet = playerProfile.entrySet();

    //iterate through the Set
    List<String> curList; //current list of choices
    int[] curHeadTail; //current list of heads/tails
    Entry<LinkedList<String>, int[]> curEntry;
    Iterator<Entry<LinkedList<String>, int[]>> i =
    profileSet.iterator();
Run Code Online (Sandbox Code Playgroud)

我想知道的是:有一种更简单的方法可以减少代码行吗?有一次,我有三重嵌套的泛型.太多了吗?

java generics

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

标签 统计

generics ×1

ios ×1

iphone ×1

java ×1

objective-c ×1

python ×1

regex ×1

uitableview ×1