所以这是我得到的代码:
NSDate *myCustomDate = [NSDate dateWithTimeIntervalSinceNow:10];
NSLog(@"My custom date: %@", myCustomDate);
Run Code Online (Sandbox Code Playgroud)
它返回:My custom date: 0023-01-23 18:37:17 +0000.
为什么今年会给出一个愚蠢的答案,而不是2011年?其他一切都是正确的.
我想要的是背景图像,其行为类似于股票主屏幕或天气应用程序:https://youtube.com/watch?v = i2Oh4GL5wBE#t = 0m54s
我只需要一个没有动画的背景图像(就像那个视频中的道路一样),它在向另一个视图滑动的同时滚动"一点".在我的应用程序中,我想通过滚动背景滑动一些ListViews.
我测试了什么:
两者都有效,但这需要一个非常大的图像,我不确定它是否可以正确缩放到不同的屏幕尺寸.此外,它的行为与原来的主屏幕不同,后者在前景变为下一个视图时移动了一点点.
我在这里阅读帖子:https://stackoverflow.com/questions/2943619/android-make-application-background-behave-like-homescreen-background
我检查了推荐的Launcher.java,它引导我进入了Workspace.java:
据我所知,它通过设置偏移来使用WallpaperManager.
mWallpaperManager.setWallpaperOffsets(getWindowToken(),
Math.max(0.f, Math.min(mScrollX/(float)scrollRange, 1.f)), 0);
Run Code Online (Sandbox Code Playgroud)
API说:
setWallpaperOffsets(IBinder windowToken,float xOffset,float yOffset)当给定窗口后面的墙纸可见时,设置当前墙纸在任何更大空间内的位置.
但据我了解,这只会改变手机本身的背景图像.
我能做什么?您是否知道开源应用程序或示例代码也是如此?可能我必须自己绘制画布(以前从未做过).请给我一些建议.
我正在开发一个MVC 3 webgrid,在我希望有一个按钮的一个列中,我已经在视图中放入以下代码时实现了这一点.
@grid.GetHtml(columns:
grid.Columns(
grid.Column("ID", "id", canSort: true),
grid.Column("Surname", "surname", canSort: true),
grid.Column("Forenames", "forename", canSort: true),
grid.Column(format: @<input type="button" value="View"/>)),
headerStyle: "header",
alternatingRowStyle: "alt",
htmlAttributes: new { id = "DataTable" }
)
Run Code Online (Sandbox Code Playgroud)
但是我希望创建网格服务器端以进行分页,但是当我将下面的代码放在操作中时,我得到了按钮列的错误.
var htmlString = grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
htmlAttributes: new { id = "DataTable" },
columns: grid.Columns(
grid.Column("ID", "id", canSort: true),
grid.Column("Surname", "surname", canSort: true),
grid.Column("Forenames", "forename", canSort: true),
grid.Column(format: @<input type='button' value='View'/>)
));
Run Code Online (Sandbox Code Playgroud)
第一个错误是"在逐字说明符后预期的关键字,标识符或字符串:@".
我在按钮列上使用了不正确的格式吗?
当我document.cookie在Javascript中访问时,它吐出来,说:
'user_credentials=5beea8874f2db9feb873828'
Run Code Online (Sandbox Code Playgroud)
基本上,似乎是一些编码信息.精细.
当我查看标题时,我确实看到完全相同的字符串被设置为user_credentials,但还有另一个值被设置为_myapplication_session=BAh7CiIQX.与user_credentials此不同,这个包括大写字母和字母后面的字母F.
所以:
_myapplication_session?这与Rails中的会话对象有关吗?_myapplication_session出现Javascript document.cookie?可能重复:
学习JQuery的最佳方法是什么?
什么是开始jquery的最佳场所?我的意思是任何好的网站?请指明链接
我正在尝试编写一个接受字符串列表或单个字符串的函数.如果它是一个字符串,那么我想将它转换为只有一个项目的数组.然后我可以循环它而不用担心错误.
那么我该如何检查变量是否是一个数组?
我已经完成了下面的各种解决方案,并创建了一个jsperf测试.
如果我有一个需要使用不同值运行的规范,以使其驱动真正的实现而不是一个天真的实现.一个例子:
it "should return 'fizz' for multiples of three" do
@fizzbuzz.get_value(3).should == "fizz"
end
Run Code Online (Sandbox Code Playgroud)
到目前为止,我还没有找到任何方法将3输入作为参数.下面的规范解决了我的问题,但我想知道这是否是推荐的方式,或者是否还有其他更好的方法.
it "should return 'fizz' for multiples of three" do
[3, 6].each{|number| @fizzbuzz.get_value(number).should == "fizz" }
end
Run Code Online (Sandbox Code Playgroud)
我不喜欢这个,因为它使用循环,它不可读,它只在运行时显示为一个规范,我宁愿让它显示为两个不同的测试.
SQL中有一个DISTINCT运算符.但是,我有一个赋值,我需要从表中获取一些不同的值,我只能使用关系代数.有办法吗?
这是我的模型的一部分:
@Entity
public class Entry
{
@Id @GeneratedValue
private long identifier;
@ElementCollection
@Column(nullable = false)
private Map<String, String> titles;
@ElementCollection
@Column(nullable = false)
@Lob
private Map<String, String> contents;
// Getters and setters, other fields and methods
}
Run Code Online (Sandbox Code Playgroud)
我使用@Lob注释,因为map"contents"的值可能很大.请注意,我不关心映射"contents"的键如何映射到数据库.我只是找不到一种方法来指定@Lob注释应该只应用于地图的值.
虽然Entry.titles没有问题地映射到数据库,但Entry.contents却没有.没有创建数据库表,MySQL/Hibernate抱怨:
Unsuccessful: create table myblog.Entry_contents (Entry_identifier bigint not null, contents longtext not null, contents_KEY longtext, primary key (Entry_identifier, contents_KEY)) type=InnoDB
BLOB/TEXT column 'contents_KEY' used in key specification without a key length
Run Code Online (Sandbox Code Playgroud)
任何想法都表示赞赏!
javascript ×2
android ×1
annotations ×1
arrays ×1
asp.net-mvc ×1
background ×1
cocoa-touch ×1
cookies ×1
hibernate ×1
iphone ×1
jpa ×1
jquery ×1
mysql ×1
nsdate ×1
objective-c ×1
rspec ×1
rspec2 ×1
ruby ×1
session ×1
tdd ×1
twitter ×1
viewflipper ×1
webgrid ×1