English 中文(简体)
How can I determine whether my UIButton s event is Touch Down?
原标题:

How can I determine whether my button s event is Touch Down?

I want to do a function like this:

if(users click on touchdown event)
{

NSLog(@"a");

}

else if(users click on touchupinside event)
{

NSLog(@"b");
}
最佳回答

Eather you set two different IBAction methods in the InterfaceBuilder or you set two different targets via:

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents

in your code while creating the button.

问题回答

You "find out" by letting the button tell you when the event happens.

Add a method (or methods) like this:

- (IBAction)myButtonClick:(id)sender;

In Interface Builder, attach the method(s) to the events you re interested in.

You create a separate method for each type of event if you want different behavior for a TouchDown as opposed to TouchUpInside.

you attach each unique event to its own IBAction





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签