Tag: performselector

即使在dispatch_async上,UILabel也不会更新

任何理由为什么我的标签不会更新? – (void)setLabel:(NSNotification*)notification { dispatch_async(dispatch_get_main_queue(), ^{ NSLog(@"setLabel"); [self.label setText:@"My Label"]; }); } 我也尝试使用performSelectorOnMainThread无济于事。 请注意,setLabel出现在日志中。 附加信息: 我也有两个其他的function,只是用不同的文本做同样的事情。 另外两个函数没有dispatch_async,但都起作用。 另外,两个工作函数的通知是由NSURLConnection(本文中的方法#2)发送的。 虽然上面的非工作函数的通知是通过调用FBRequestConnection发送的(请参阅本文 )。 为了清楚起见,我的另外两个工作职能如下: – (void)setLabel2:(NSNotification*)notification { NSLog(@"setLabel2"); [self.label setText:@"My Label 2"]; } – (void)setLabel3:(NSNotification*)notification { NSLog(@"setLabel3"); [self.label setText:@"My Label 3"]; } 是的,我尝试删除我的代码中的dispatch_async。 事实上,原来没有dispatch_async,因为其他两个工作。

如何解决“没有已知的select器实例方法performSelector:withObject:afterDelay:'”当迁移到ARC?

ARC迁移工具在开始迁移之前拒绝接受此代码: [self.delegate performSelector:@selector(overlayDismissed:) withObject:self afterDelay:0]; 委托人被强制使用协议来实现这个方法,它应该可以正常工作: @protocol OverlayDelegate <NSObject> – (void)overlayDismissed:(Overlay*)overlay; @end @interface Overlay : UIImageView { id<OverlayDelegate> delegate; } @property (nonatomic, assign) id<OverlayDelegate> delegate; ARC有什么问题? 为什么它告诉我有没有已知的实例方法select器performSelector:withObject:afterDelay:'?

如何尽快调用一个方法,但最快在下一次运行循环迭代?

我需要一个保存的方式来说:“iOS,我希望这个方法尽快执行,但不是在这个运行循环迭代中,最早在下一个,但请不要在这个,谢谢。 现在我总是这样做: [self performSelector:@selector(doSomethingInNextRunLoop) withObject:nil afterDelay:0]; [self doSomeOtherThings]; 假设-doSomeOtherThings将始终执行一些其他-doSomethingInNextRunLoop 。 该文件说: 指定延迟0不一定会导致select器立即执行。 select器仍在线程的运行循环中排队,并尽快执行。 所以基本上可能会发生这样的情况:即时调用方法就好像我刚刚发送了一个直接的消息,导致-doSomethingInNextRunLoop在执行之前执行一些其他的-doSomeOtherThings ? 我怎样才能绝对确保它将被称为asap,但从来没有在这同样的运行循环迭代? 为了澄清措辞:运行循环我的意思是主线程,所有方法必须返回的迭代,直到线程再次准备好新的事件。

在Objective-C中如何等待

我想在2秒后更改我的UILabel的文本。 我尝试将我的UILabel的文本设置为“一个文本” ,并使用sleep(2) ,最后将文本更改为“另一个文本” 。 但sleep(2)只冻结了应用程序,并设置了“另一个文本” ,而不显示“文本” 2秒。 如何显示“文本” 2秒钟,然后显示“另一个文本” ?

Coregraphics(iOS)中的内存pipe理

我正在绘制应用程序,我正在使用CGlayers进行绘图,所以我打开canvas,点击一个button, 我使用的UIBezierPath,然后将其转换为CGPath在touchesMoved下面,然后使用它来绘制 -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if (ctr == 4) { m_touchMoved = true; self.currentPath = [[DrawingPath alloc] init]; [self.currentPath setPathColor:self.lineColor]; self.currentPath.pathWidth = [NSString stringWithFormat:@"%f",self.lineWidth]; pts[3] = midPoint(pts[2], pts[4]);// move the endpoint to the middle of the line joining the second control point of the first Bezier segment and the first control point of […]