在Apple的消息应用程序中,当您单击通讯员的名称并切换到对话的表格视图(每个消息都有气球)时,表格会一直滚动到最后.没有动画或任何东西,它就在那里.
同样,在Tweetie 2中,当您加载推文视图时,它会显示在您上次查看它的位置.没有动画到达那里,它就在那里,好像上面没有任何单元格被加载.
这些应用程序如何做到这一点?他们scrollToRowAtIndexPath:atScrollPosition:animated:在桌面控制器的某个地方打电话吗?如果是这样,他们怎么知道要传递给atScrollPosition:谁?它叫什么方法?
假设有两个单链表,它们在某个点相交并成为单个链表.
两个列表的头部或起始指针都是已知的,但交叉节点是未知的.此外,列表中每个列表中的节点数量在它们相交之前是未知的,并且两个列表可能具有不同,即List1在到达交叉点之前可能有n个节点,并且List2可能在到达交点之前有m个节点,其中m和n可以是
一种已知或简单的解决方案是将第一列表中的每个节点指针与第二列表中的每个其他节点指针进行比较,匹配节点指针将通过该指针引导我们到交叉节点.但是,在这种情况下,时间复杂度将是O(n 2),这将是很高的.
找到交叉节点的最有效方法是什么?
我在OS 3.x上有以下代码
NSString *stringDate = @"2010-06-21T20:06:36+00:00";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
NSDate *theDate = [dateFormatter dateFromString:stringDate];
NSLog(@"%@",[dateFormatter stringFromDate:theDate]);
Run Code Online (Sandbox Code Playgroud)
但现在在iOS4模拟器下的最新xcode 3.2.3中,变量theDate为零.
我查看了类引用,并没有看到任何已弃用或使用这些特定方法为iOS4实现不同的内容.我遗漏了什么?
我有这个查询,它在MySQL中运行良好
SELECT ((ACOS(SIN(12.345 * PI() / 180) * SIN(lat * PI() / 180) +
COS(12.345 * PI() / 180) * COS(lat * PI() / 180) * COS((67.89 - lon) *
PI() / 180)) * 180 / PI()) * 60 * 1.1515 * 1.609344) AS distance, poi.*
FROM poi
WHERE lang='eng'
HAVING distance<='30'
Run Code Online (Sandbox Code Playgroud)
距离以公里为单位,输入为lat=12.345和lon=67.89
SQLite是3,我无法在Android上运行自定义函数.我也没有acos()等......因为它不是标准SQLite的一部分.
如何在SQLite中进行上述查询?
我有正在使用的正则表达式的问题,但不知道如何继续使用它们.我收到错误"无法识别的转义序列".
我试图列出所有可能具有以下代码中列出的格式的电话号码的文件
static void Main(string[] args)
{
//string pattern1 = "xxx-xxx-xxxx";
//string pattern2 = "xxx.xxx.xxxx";
//string pattern3 = "(xxx) xxx-xxxx";
string[] fileEntries = Directory.GetFiles(@"C:\BTISTestDir");
foreach (string filename in fileEntries)
{
StreamReader reader = new StreamReader(filename);
string content = reader.ReadToEnd();
reader.Close();
string regexPattern1 = "^(\d{3}\.){2}\d{4}$";
string regexPattern2 = "^((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}$";
if(Regex.IsMatch(content, regexPattern1))
Console.WriteLine("File found: " + filename);
if(Regex.IsMatch(content, regexPattern2))
Console.WriteLine("File found: " + filename);
}
Console.WriteLine(Environment.NewLine + "Finished");
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
任何帮助深表感谢.
如何在Python 2.6中删除XML字符串中的空格和换行符?我尝试了以下包:
etree:这个片段保留了原始的空格:
xmlStr = '''<root>
<head></head>
<content></content>
</root>'''
xmlElement = xml.etree.ElementTree.XML(xmlStr)
xmlStr = xml.etree.ElementTree.tostring(xmlElement, 'UTF-8')
print xmlStr
Run Code Online (Sandbox Code Playgroud)
我不能使用提供method参数的Python 2.7 .
minidom:同样的:
xmlDocument = xml.dom.minidom.parseString(xmlStr)
xmlStr = xmlDocument.toprettyxml(indent='', newl='', encoding='UTF-8')
Run Code Online (Sandbox Code Playgroud) PCRE具有称为递归模式的功能,可用于匹配嵌套的子组.例如,考虑"语法"
Q -> \w | '[' A ';' Q* ','? Q* ']' | '<' A '>'
A -> (Q | ',')*
// to match ^A$.
Run Code Online (Sandbox Code Playgroud)
它可以在具有模式的PCRE中完成
^((?:,|(\w|\[(?1);(?2)*,?(?2)*\]|<(?1)>))*)$
Run Code Online (Sandbox Code Playgroud)
(示例测试用例:http://www.ideone.com/L4lHE)
abcdefg abc,def,ghi abc,,,def ,,,,,, [abc;] [a,bc;] sss[abc;d] as[abc;d,e] [abc;d,e][fgh;j,k]
<abc> [<a>b;<c,d>,<e,f>] <a,b,c> <a,bb,c> <,,,> <> <><> <>,<> a<<<<>>><a>> <<<<<>>>><><<<>>>>
<z>[a;b] <z[a;b]> [[;];] [,;,] [;[;]] [<[;]>;<[;][;,<[;,]>]>]
<a bc> <abc<de> [a<b;c>;d,e] [a] <<<<<>>>><><<<>>>>> <<<<<>>>><><<<>>> [abc;def;] [[;],] [;,,] [abc;d,e,f]
[<[;]>;<[;][;,<[;,]>]]> <z[a;b>]
.NET中没有递归模式.相反,它为基于堆栈的操作提供了平衡组,以匹配简单的嵌套模式.
是否可以将上述PCRE模式转换为.NET Regex风格?
(是的,我知道最好不要使用正则表达式.这只是一个理论问题.)
我有一个显示在CGRect中的图像.如何在视图中居中矩形?
这是我的代码:
UIImage * image = [UIImage imageNamed:place.image];
CGRect rect = CGRectMake(10.0f, 90.0f, image.size.width, image.size.height);
UIImageView * imageView = [[UIImageView alloc] initWithFrame:rect];
[imageView setImage:image];
Run Code Online (Sandbox Code Playgroud)
我已经尝试过imageView.center但没有效果.
提前致谢.
无论如何我可以将数据从fstream(一个文件)传输到stringstream(内存中的流)吗?
目前,我正在使用缓冲区,但这需要双倍的内存,因为您需要将数据复制到缓冲区,然后将缓冲区复制到字符串流,直到您删除缓冲区,数据在内存中重复.
std::fstream fWrite(fName,std::ios::binary | std::ios::in | std::ios::out);
fWrite.seekg(0,std::ios::end); //Seek to the end
int fLen = fWrite.tellg(); //Get length of file
fWrite.seekg(0,std::ios::beg); //Seek back to beginning
char* fileBuffer = new char[fLen];
fWrite.read(fileBuffer,fLen);
Write(fileBuffer,fLen); //This writes the buffer to the stringstream
delete fileBuffer;`
Run Code Online (Sandbox Code Playgroud)
有没有人知道如何在不使用inbetween缓冲区的情况下将整个文件写入字符串流?
Xcode没有给出我的(想到的)拼写错误:
NSString *theme = [[NSUserDefaults standardUserDefaults] objectForKey:@"theme"];
NSLog(@"Theme: %@", theme ?: @"Default");
Run Code Online (Sandbox Code Playgroud)
事实证明:
NSLog(@"Theme: %@", theme ?: @"Default");
Run Code Online (Sandbox Code Playgroud)
与以下相同:
NSLog(@"Theme: %@", theme ? theme : @"Default");
Run Code Online (Sandbox Code Playgroud)
iphone ×3
objective-c ×3
regex ×2
.net ×1
algorithm ×1
android ×1
buffer ×1
c ×1
c# ×1
c++ ×1
elementtree ×1
fstream ×1
ios4 ×1
linked-list ×1
pcre ×1
python ×1
python-2.6 ×1
sql ×1
sqlite ×1
stl ×1
stringstream ×1
uiimage ×1
uitableview ×1
xml ×1