我的-drawInContext:方法中有一个包含一些复杂绘图代码的图层.我正在尝试最小化我需要做的绘图量,所以我使用-setNeedsDisplayInRect:仅更新已更改的部分.这是非常好的工作.但是,当图形系统更新我的图层时,它会使用交叉淡入淡出从旧图像过渡到新图像.我希望它能立即切换.
我已经尝试使用CATransaction来关闭操作并将持续时间设置为零,并且都不起作用.这是我正在使用的代码:
[CATransaction begin];
[CATransaction setDisableActions: YES];
[self setNeedsDisplayInRect: rect];
[CATransaction commit];
Run Code Online (Sandbox Code Playgroud)
我应该使用不同的CATransaction方法(我也尝试过-setValue:forKey:使用kCATransactionDisableActions,结果相同).
我是Python编程的新手,所以我有这个问题:
如何使用Mac OS X将Python应用程序活动记录到/ var/log中?
我尝试使用syslog模块,但它似乎没有写任何东西.我也尝试使用日志记录模块,但我总是遇到权限错误.
我该怎么做?
更新:
import logging
import time
LOG_FILENAME = "/var/log/writeup.log" + time.strftime("%Y-%m-%d")
LOG_FORMAT = "%(asctime)s - %(filename)s - %(levelname)s - %(message)s"
log = logging.getLogger("main.py")
log.setLevel(logging.DEBUG)
ch = logging.FileHandler(LOG_FILENAME)
ch.setLevel(logging.DEBUG)
format = logging.Formatter(LOG_FORMAT)
ch.setFormatter(format)
log.addHandler(ch)
Run Code Online (Sandbox Code Playgroud) 我在Java中使用Graphics2D来缩放和旋转我绘制的图片.我现在希望能够在我点击图片中的某个点时告诉原始坐标是什么.因此,考虑到旋转和缩放的坐标,我想计算原始坐标.有一个简单的方法吗?
如果将多个属性应用于成员,例如
[Foo]
[Bar]
void Baz() { ... }
Run Code Online (Sandbox Code Playgroud)
那么CLR/.NET规范是否保证在通过反射检索它们时将检索它们的顺序(例如Attribute.GetCustomAttributes)?这些方法的文档并没有明确说明,虽然它们似乎是按照它们应用的顺序返回的,但我不想依赖于未记录的行为,因为它只是在寻找麻烦.
至于为什么这可能很重要,想象一下这些属性用于表示该方法应该有一系列拦截器,这些拦截器应该以特定的顺序运行.
我会说这几乎是一个样式/可读性的东西,虽然我确实看到几乎所有的objective-c/cocoa按照"METHOD_002"格式化.我只是好奇如果"METHOD_001"被认为是坏的风格,将所有声明放在方法的顶部是有好处的,但是如果你没有声明使用它们的对象,那么在可读性方面又有缺点吗?
METHOD_001
-(IBAction)dateButtonPressed {
NSDate *dateSelected;
NSString *dateString;
NSArray *dateItems;
NSString *alertMessage;
UIAlertView *alert;
dateSelected = [datePicker date];
dateString = [[NSString alloc] initWithFormat:@"%@", dateSelected];
dateItems = [dateString componentsSeparatedByString:@" "];
alertMessage = [[NSString alloc] initWithFormat:@"Date: %@ Time: %@", [dateItems objectAtIndex:0], [dateItems objectAtIndex:1]];
alert = [[UIAlertView alloc] initWithTitle:@"You Selected"
message:alertMessage
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
[alertMessage release];
[dateString release];
}
Run Code Online (Sandbox Code Playgroud)
METHOD_002
-(IBAction)dateButtonPressed {
NSDate *dateSelected = [datePicker date];
NSString *dateString = [[NSString alloc] initWithFormat:@"%@", dateSelected];
NSArray *dateItems = [dateString componentsSeparatedByString:@" …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个PowerShell脚本,创建一个新的IIS 6网站,并设置应用程序池,通配符应用程序映射,ASP.NET版本等.
在Internet上进行了大量搜索之后,我发现了一个脚本,它允许我创建一个新的Web站点,但不能修改我需要的所有属性.
$newWebsiteName = "WebSiteName"
$newWebsiteIpAddress = "192.168.1.100"
$newWebSiteDirPath = "c:\inetpub\wwwroot\WebSiteName"
$iisWebService = Get-WmiObject -namespace "root\MicrosoftIISv2"
-class "IIsWebService"
$bindingClass = [wmiclass]'root\MicrosoftIISv2:ServerBinding'
$bindings = $bindingClass.CreateInstance()
$bindings.IP = $newWebsiteIpAddress
$bindings.Port = "80"
$bindings.Hostname = ""
$result = $iisWebService.CreateNewSite
($newWebsiteName, $bindings, $newWebSiteDirPath)
Run Code Online (Sandbox Code Playgroud)
任何有关如何扩展上述示例的帮助非常感谢.
我正在尝试使用内置本地化的应用程序,但我想要一种方法,我可以在文本中创建一个Web链接,URL在其他地方定义(为了便于维护).
所以,我在res/values/strings.xml中有我的链接:
<?xml version="1.0" encoding="utf-8"?>
<resources>
...
<string name="link1">http://some.link.com</string>
<string name="link2">http://some.link2.com</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
和我在res/values-en-rGB/strings.xml中的本地化文本
<?xml version="1.0" encoding="utf-8"?>
<resources>
...
<string name="sampleText">Sample text\nMore text and link1\nMore text and link2.</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
我没有对这一点进行过测试,但是从developer.android.com的本地化部分开始,它表示这种减少内容重复的方法应该可行,但我不知道我应该把意大利文放在哪个文件夹中.它会在'res/values-it-rIT/strings.xml'中吗?让我们假设我也有其他各种语言.
我正在寻找一种方法来获取基本本地化的'sampleText'并插入我的html链接,并在点击时让它们工作.到目前为止,我尝试了两种方法:
1,
在'sampleText'(%s)中添加一些格式:
<string name="sampleText">Sample text\nMore text and <a href="%s">link1</a>\nMore text and <a href="%s">link2</a>.</string>
Run Code Online (Sandbox Code Playgroud)
然后像这样处理文本:
TextView tv = (TextView) findViewById(R.id.textHolder);
tv.setText(getResources().getString(R.string.sampleText, getResources().getString(R.string.link1), getResources().getString(R.string.link2)));
Run Code Online (Sandbox Code Playgroud)
但是,当我点击链接时,这不起作用,即使链接文本正在放入正确的位置.
2,我尝试使用Linkify但正则表达式路线可能很难,因为我正在寻找支持非拉丁语言.我试图在链接文本周围放置一个自定义的xml标记,然后执行以下操作:
Pattern wordMatcher = Pattern.compile("<span1>.*</span1>");
String viewURL = "content://" + getResources().getString(R.string.someLink);
Linkify.addLinks(tv, wordMatcher , viewURL );
Run Code Online (Sandbox Code Playgroud)
但这也不起作用.
那么,我想知道是否有一种方法可以动态地将多个URL添加到同一文本的不同部分,这些部分将链接到Web内容?
我的视图控制器中有一个表(我们称之为TVC1).我在TVC1中使用了行,因此除了TVC1上的数据之外,用户还可以输入更多数据.因此,当有人在TVC1中点击特定行时,它将显示另一个视图控制器(让我们称之为TVC2).但是,当显示TVC2时,TVC1中的所有数据都被清除.如何在TVC1中保存数据?我应该通过应用代表进行吗?
DescriptionInputViewController *descriptionController = [[DescriptionInputViewController alloc]
initWithNibName:@"DescriptionInputView"
bundle:nil];
[self presentModalViewController:navController animated:YES];
[self.navigationController pushViewController:descriptionController animated:YES];
[descriptionController release];
Run Code Online (Sandbox Code Playgroud) 我在Maven项目B(它是项目A的孩子)中的测试代码有类似的东西
String filePath = "src/main/webapp";
//do something with the filePath
Run Code Online (Sandbox Code Playgroud)
当我从子项运行项目(即B级)时,上面的测试用例运行正常,但是当我从父项目A运行时(即,在父级别执行mvn安装),这会失败,因为很明显没有名为"src /的文件夹"在父级别下的main/webapp(但是在子级别可用).
我知道我可以做一些编码,检查一下测试用例是否从父/子模块运行,但显然我想知道其他人在遇到这个问题时做了什么?
不,我不能使用类路径(出于各种无聊的原因).
我也尝试了相对路径,但随后测试用例开始了解太多.实际上有解决方案吗?
更新(12月2日) - 我在webapp文件夹下有一个web.xml,并使用该web.xml在测试用例中创建一个jetty服务器.理想情况下,src/main/webapp不会放在类路径中.WAR插件使用它来打包WAR.现在,我尝试了另一种方法,我将web.xml放在src/main/resource/console-webapp/WEB-INF/web.xml目录中,并更改了maven war插件中的webXml属性.这似乎解决了我的问题.但是,在输出WAR中我有一个web.xml和另一个冗余web.xml(由于它在类路径中而被复制).
我尝试过"packageExcludes"和"webResources/excludes",并获得了war插件,省略了第二个web.xml,但仍然复制了目录"console-webapp"(尽管是空的).有没有办法告诉maven war插件完全忽略一个目录(即什么是蚂蚁模式?)
我想写一个简单的Web应用程序,可以连接到数据库并显示简单的文本和图像.我知道一些编程 - 主要是C.我也有很短的时间来学习与之相关的语言和技术.哪种语言会很好/也是一个很好的起点
iphone ×2
java ×2
objective-c ×2
.net ×1
android ×1
attributes ×1
calayer ×1
cocoa-touch ×1
controller ×1
coordinates ×1
database ×1
dynamic ×1
graphics ×1
hyperlink ×1
iis-6 ×1
ios ×1
junit ×1
localization ×1
logging ×1
macos ×1
maven-2 ×1
powershell ×1
python ×1
reverse ×1
text ×1
view ×1
web ×1
wmi ×1