问题列表 - 第31672页

使用CABasicAnimation时,CALayer未绘制其内容

我有一个自定义CALayer子类的应用程序.在这个图层子类中,我已经覆盖了该- (void) drawInContext:(CGContextRef)ctx方法.这工作正常,我的所有自定义内容都被绘制.

现在我想添加一个自定义属性,当内容发生变化时,该属性会被动画化.我需要在动画运行时重绘.我添加了以下问题的答案中给出的属性:动画CALayer子类的自定义属性

我还为我的图层添加了此属性的CABasicAnimation实例:

CABasicAnimation* theAnimation=[CABasicAnimation animationWithKeyPath:@"moveContentToLeft"];
theAnimation.duration=1.0;
theAnimation.fromValue=[NSNumber numberWithFloat:0.0];
theAnimation.toValue=[NSNumber numberWithFloat:10.0];
[area addAnimation:theAnimation forKey:@"moveContentToLeft"];
Run Code Online (Sandbox Code Playgroud)

在我的draw方法中,我有一个NSLog语句,在其中我输出my属性的值,我正在动画.

我的问题是,一旦动画启动,就会清除图层子类的所有内容.NSLog输出我的属性的值,该属性被内插(因此drawInContext方法)被调用.但不知何故,它绘制的东西在动画中是不可见的.在动画结束时,原始内容再次可见.

目前在绘制图层时尚未使用动画属性,因此我希望再次绘制正常内容,并获得带有插值的NSLog输出.

我的图层是另一个图层的子图层(在UIView中).我试图在绘图方法的末尾重绘超级图层(调用_parent setNeedsDisplay [parent是父视图的ivar]).这没有用.我也觉得这样做不是一个好主意.

我希望有人可以帮我解决这个问题.

更新

感谢Matt Long的示例项目,我可以看到我的问题出在绘图方法中.我扩展了他的项目,因此它显示了同样的问题.我认为它比原始代码更简单;)

- (void)drawInContext:(CGContextRef)ctx
{
  NSLog(@"Getting called: Bob: %i", [self bob]);

  CGMutablePathRef path = CGPathCreateMutable();
  CGPathAddRect(path, NULL, CGRectMake(50 + [self bob], 50, 100, 100)); 
  CGContextAddPath(ctx, path);
  CGContextSetStrokeColorWithColor(ctx, [UIColor redColor].CGColor);
  CGContextSetLineWidth(ctx, 1.0);
  CGContextStrokePath(ctx);
  CGPathRelease(path);

  [_test testInContext:ctx]; // here is the problem
}
Run Code Online (Sandbox Code Playgroud)

ivar _test是一个自定义类,包含一些绘图代码(目前它绘制一个绿色框).现在的问题是动画运行时不会绘制这个绿色框.动画结束后,绿色框再次可见.扩展示例项目:http://dl.dropbox.com/u/5426092/ArbitraryPropertyAnimationNew.zip

iphone core-animation objective-c

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

当视图获得关键焦点时,Cocoa NSVIew会发出通知吗?

如果NSView获得关键焦点,我如何获得通知?

我期待一个像NSWindow的"windowDidBecomeKey"这样的方法,但要么我是盲目的,要么就是这样的NSView.

cocoa nsview

4
推荐指数
1
解决办法
4284
查看次数

正确的公式:4 x if&else

我有4个IF句子,之后我想说别的(不是if的条件)但是我得到了一个错误.

我有:

if (condition 1) { }
if (condition 2) { }
if (condition 3) { }
if (condition 4) { }
else { }
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么 ?

php

0
推荐指数
2
解决办法
113
查看次数

通过Intent从一个类传递数据到另一个类并且无法捕获它?

我有两个这样的String Arrays,

String[] htmlArray = {
      "file:///android_asset/Pinocchio/OPS/chapter-001.xml",
      "file:///android_asset/Pinocchio/OPS/chapter-002.xml",

      "file:///android_asset/Pinocchio/OPS/chapter-035.xml",
      "file:///android_asset/Pinocchio/OPS/chapter-035.xml" 
};

String[] htmlArray1 = {
      "file:///android_asset/Harry_Potter/OEBPS/part1.xhtml",
      "file:///android_asset/Harry_Potter/OEBPS/part2_split_000.xhtml",

      "file:///android_asset/Harry_Potter/OEBPS/part18_split_000.xhtml",
      "file:///android_asset/Harry_Potter/OEBPS/part18_split_001.xhtml", 
};
Run Code Online (Sandbox Code Playgroud)

然后,我把两个ImageView放在另一个类中,

private void init() {
    pino_cover = (ImageView) findViewById(R.id.pino_cover);
    pino_cover.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
        Intent reader=new Intent(instance,ReaderScreen.class);
        reader.putExtra("pino",true);
        startActivity(reader);
      }
    });

    harry_cover=(ImageView) findViewById(R.id.harry_cover);
    harry_cover.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
        Intent reader=new Intent(instance,ReaderScreen.class);
        reader.putExtra("harry",true);
        startActivity(reader);
      }
    });
  }
Run Code Online (Sandbox Code Playgroud)

然后,如果我点击Pino图像,我可以通过htmlArray获取数据.

Intent i=getIntent();
      Bundle b = i.getExtras();
       String newText = b.
       String setext=b.getString("harry");
      if (newText=="pino")    
        pages …
Run Code Online (Sandbox Code Playgroud)

android android-intent

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

Visual Studio中的错误消息

当我按下"开始调试"按钮时出现以下错误消息:"存在部署错误.继续?" 知道为什么会显示此错误消息吗?

visual-studio

9
推荐指数
1
解决办法
9829
查看次数

关于这个java类可以说什么?

我被问到这个问题:我无法回答 - 这里有任何答案吗?

关于拥有1000行代码的java类,1-n方法有100行和n + 1到m方法有200行代码,可以说什么?

我想,类应该可以有1000行代码和方法也可以有100-200行代码 - 所以我没有回答考虑到这个类完全没问题.

是否存在与java类的行数相关的编译时性能?还是java方法有?有没有标准 - 如果是这样,那么技术上怎么能证明这一点?

谢谢!

java

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

如何将可选参数传递给C#中的方法?

如何将可选参数传递给C#中的方法?

假设我创建了一个名为Sendcommand的方法

public void SendCommand(String command,string strfilename)
{

    if (command == "NLST *" ) //Listing Files from Server.
    {
        //code
    }
    else if (command == "STOR " + Path.GetFileName(uploadfilename)) //Uploading file to Server
    {
        //code
    }
    else if ...
}
Run Code Online (Sandbox Code Playgroud)

现在我想在main方法中调用此方法

Sendcommand("STOR ", filename);
Sendcommand("LIST"); // In this case i dont want to pass the second parameter
Run Code Online (Sandbox Code Playgroud)

怎么实现呢?

.net optional-parameters c#-4.0

9
推荐指数
3
解决办法
4万
查看次数

进入目录后执行bash功能

我想在输入新目录时执行特定的bash函数.有些想法:

alias cd="cd $@ && myfunction"
Run Code Online (Sandbox Code Playgroud)

$@在那里不起作用,添加反斜杠也无济于事.我也有点担心与CD搞乱,这将是很好,如果这个工作了哪些改变目录,像其他的命令pushdpopd.

有更好的别名/命令吗?

bash cd function

19
推荐指数
3
解决办法
7729
查看次数

我怎样才能编译程序员Dvorak?

我正在尝试编译开源项目Programmer Dvorak.问题是它有点旧,并且不使用当前版本的构建工具构建.

您可以在我项目的Google代码页上看到我在线修改的完整源代码.版本2是原始项目中未修改的源文件.修订版3是我做出所有重大更改的地方.您可以在此处看到两个修订版之间的差异.

剩下的唯一明显问题是一些LINK警告:

  • LNK4254(例如section '.edata' (40000040) merged into '.data' (C0000040) with different attributes.) - 我在这里问了一个独立版本的问题.
  • LNK4210(例如.CRT section exists; there may be unhandled static initializers or terminators)

我该如何修复这些警告?我可以忽略它们吗?

尽管有这些警告,它仍然会产生一个exe.但是,如果我继续运行它,它将无法正确安装,我需要求助于系统还原才能再次安装正式版本.

这可能是因为警告或仅仅是因为我没有正确修改项目.

我还需要做些什么来使这个项目可以安装?


构建过程(以及对我的修改的解释):

它说您需要Windows DDK,但似乎Windows驱动程序工具包已经取代它,所以我得到了它.我只安装了"Build Environments".

根据Readme.txt,你应该运行:

build-layout && build-installer
Run Code Online (Sandbox Code Playgroud)

2. build-layout.bat运行.

我不得不修改这个文件(参见这里的差异):

  • WinDDK路径被修改,因为我有一个较新的版本(MOD-1).
  • set PATH=... %WINDDK%\bin\x86\x86;因为link.exe …

c linker open-source driver wdk

11
推荐指数
1
解决办法
1723
查看次数

如何为PostgreSQL设置千位分隔符?

我想使用千位分隔符格式化长数字.它可以使用to_char函数完成,如:

SELECT TO_CHAR(76543210.98, '999G999G990D00')
Run Code Online (Sandbox Code Playgroud)

但是当我使用UTF-8编码的PostgreSQL服务器在波兰语版本的Windows上时,SELECT结束于:

ERROR:  invalid byte sequence for encoding "UTF8": 0xa0
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".
Run Code Online (Sandbox Code Playgroud)

to_char模式G中描述为:组分隔符(使用区域设置).当服务器在具有波兰语语言环境的Linux上运行时,此SELECT可以正常运行.

作为一种解决方法,我使用空格而不是G格式字符串,但我认为应该像在Oracle中一样设置千位分隔符:

ALTER SESSION SET NLS_NUMERIC_CHARACTERS=', ';
Run Code Online (Sandbox Code Playgroud)

这样的设置是否适用于PostgreSQL?

postgresql formatting locale

15
推荐指数
2
解决办法
2万
查看次数