有没有人知道一种好方法来测试存储在var中的一个元素是否是另一个元素的后代,也存储在var中?
我不需要element1.isChildOf('selector'),这很容易.
我需要element1.isChildOf(element2)
element2.find(element1).size() > 0 似乎没有用.
我不想写一个插件.each用于测试每个孩子,如果我可以避免它.
我有一个tableView,其中包含带有电话号码的单元格.该应用程序不是拨打号码.请参阅下面的代码
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 2) {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
NSString *numberToDial = [NSString stringWithFormat:@"tel:%@", selectedCell.detailTextLabel.text];
NSLog(@"%@",numberToDial);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:numberToDial]];
}
}
Run Code Online (Sandbox Code Playgroud)
控制台输出:
2010-03-08 01:32:30.830 AIB[1217:207] tel:01 8350098
如您所见,该号码将转到控制台,但不会拨打.奇怪的是,如果我将最后一个语句更改为:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:171"]];
Run Code Online (Sandbox Code Playgroud)
手机拨打号码171没有任何问题
我的特定问题的解决方案是,如下所示,从电话号码中删除空格.我实现了如下:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 2) {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
NSMutableString *numberToDial = [NSMutableString stringWithFormat:@"tel:%@", selectedCell.detailTextLabel.text];
[numberToDial replaceOccurrencesOfString:@" "
withString:@""
options:NSLiteralSearch
range:NSMakeRange(0, [numberToDial length])];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:numberToDial]];
}
}
Run Code Online (Sandbox Code Playgroud) 我想用仅使用AC3的calibri.ttf显示"Hello World".我该怎么办?
在网上找到了两个解决方案,但我不能使用它们中的任何一个 - Adobe文档站点需要使用Flash CS4.(不知道如何在Flex Builder中使用它) - embed标记方法需要FLEX SDK
是否可以在使用Flex Builder的actionscript项目中使用纯ActionScript 3嵌入字体?
我正在尝试使用CredWrite,但出现ERROR_INVALID_PARAMETER 87 (0x57)错误。目的是有一个安全的位置来保存我的 .net WPF 应用程序的用户密码。
我的代码:
public class CredMan
{
private const string TARGET_PREFIX = "myappname:";
public static void SavePassword(string username, string password)
{
Win32CredMan.Credential cred = new Win32CredMan.Credential();
cred.Flags = 0;
cred.Type = Win32CredMan.CRED_TYPE.GENERIC;
cred.TargetName = TARGET_PREFIX + username;
var encoding = new System.Text.UTF8Encoding();
cred.CredentialBlob = encoding.GetBytes(password);
cred.Persist = Win32CredMan.CRED_PERSIST.LOCAL_MACHINE;
cred.UserName = username;
bool isGood = Win32CredMan.CredWrite(cred, 0);
int lastError = Marshal.GetLastWin32Error();
}
}
Run Code Online (Sandbox Code Playgroud)
这是 win32 包装器:(大部分来自pinvoke.net)
internal class Win32CredMan
{
[DllImport("Advapi32.dll", …Run Code Online (Sandbox Code Playgroud) 我需要检测管理员中某些模型的某些字段何时发生了变化,以便稍后根据更改的字段和这些字段的上一个/当前值发送通知.
我试着用ModelForm和重写save()方法,但形式的self.cleaned_data和seld.instance已有的字段的新值.
我对Atkin筛选的实施要么忽略接近极限的质数,要么忽略接近极限的复合材料.虽然有些限制有效,有些却没有.对于什么是错误,我完全感到困惑.
def AtkinSieve (limit):
results = [2,3,5]
sieve = [False]*limit
factor = int(math.sqrt(lim))
for i in range(1,factor):
for j in range(1, factor):
n = 4*i**2+j**2
if (n <= lim) and (n % 12 == 1 or n % 12 == 5):
sieve[n] = not sieve[n]
n = 3*i**2+j**2
if (n <= lim) and (n % 12 == 7):
sieve[n] = not sieve[n]
if i>j:
n = 3*i**2-j**2
if (n <= lim) and (n % 12 == …Run Code Online (Sandbox Code Playgroud) 我需要有关如何编写一个C程序的想法,该程序保留指定数量的MB RAM直到一个键[ex.在Linux 2.6 32位系统上按下任意键.
*
/.eat_ram.out 200
# If free -m is execute at this time, it should report 200 MB more in the used section, than before running the program.
[Any key is pressed]
# Now all the reserved RAM should be released and the program exits.
*
Run Code Online (Sandbox Code Playgroud)
它是程序的核心功能[保留RAM]我不知道怎么做,从命令行获取参数,打印[按任意键]等等对我来说不是问题.
关于如何做到这一点的任何想法?
我必须手工计算下一个工作的运行日期,你能帮助我吗?
举一个简单的例子,我在页面上多次重复了以下块(它是动态生成的):
<div class="box">
<div class="something1"></div>
<div class="something2">
<a class="mylink">My link</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
点击后,我可以通过以下方式访问链接的父级:
$(".mylink").click(function() {
$(this).parents(".box").fadeOut("fast");
});
Run Code Online (Sandbox Code Playgroud)
但是......我需要找到<div class="something1">那个特定的父母.
基本上,有人可以告诉我如何引用更高级别的兄弟而不能直接引用它吗?我们称之为大哥哥.直接引用大哥的类名会导致页面上该元素的每个实例淡出 - 这不是理想的效果.
我试过了:
parents(".box .something1") ... no luck.
parents(".box > .something1") ... no luck.
siblings() ... no luck.
Run Code Online (Sandbox Code Playgroud)
任何人?谢谢.
jquery ×2
.net ×1
asp.net ×1
c ×1
c# ×1
cocoa-touch ×1
credentials ×1
django ×1
django-admin ×1
django-forms ×1
flash ×1
iphone ×1
linux ×1
marshalling ×1
math ×1
memory ×1
parent ×1
php ×1
primes ×1
python ×1
ram ×1
siblings ×1
sql ×1
sql-server ×1
winapi ×1