Iphone-MultiButton-Events
I Have One Xib File IN Which There Are About 50 Buttons..
And All Are Have Same Functionality... Like On Click I Change Background Image (Select)And... And Second Time Click Also Change Background Packet (Deselect) ..
开发者_开发技巧If I Make All Button Own Events .. Then It's Ok..
But I Want To Create Single Function Which Handles All Buttons...
I Try It.. I Can't Get Specific Typecasting
Coding
.h File
-(IBAction) BtnShpPress:(id)sender;
.m File
-(IBAction) BtnShpPress:(id)sender
{
UIButton *BtnShp= (UIButton * ) sender;
NSString *Str = BtnShp.name; //Here I Ca't Get Specific Object
}
And I Apply This Event On 4 Buttons - TouchDown Events
-(IBAction) BtnShpPress:(id)sender
{
UIButton *BtnShp= (UIButton * ) sender;
NSString *Str = [BtnShp currentTitle]; //This gives title of button
}
You can also set tag and access them too using button.tag
use this to get title -
NSString *Str = [[BtnShp titleLabel] text];
精彩评论