简体   繁体   中英

how can i fire button action event without any user action iphone xcode?

how can i fire button action event without any user action?

pls give me any sample..

UIButtons are subclass of UIControl. They use the sendActionsForControlEvents: method to send out events. You can call that method on the button (or control) to have the actions sent.

[theButton  sendActionsForControlEvents: UIControlEventTouchUpInside];

If user dont want to fire action on button,why do you show button,without showing button,u can do action.I think u need dynamic code (without interface builder),the code is

 [button1 addTarget:self action:@selector(action1:) forControlEvents:UIControlEventTouchUpInside];

 -(void) action1:(id)sender;

{ } hope this will help....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM