Monday, August 5, 2013

Detecting different button clicks in xcode

Here i have explained how you can detect which button is clicked:- 

1) Assign tag to every button in the properties of button.

2) create an IBAction and attach to every button.

   NSLog(@"%d",[sender tag]);

3) whenever you click a button it would print its tag.

Transfer your tag to next page: 

    Main *subCat=[[Category alloc]initWithNibName:@"Category" bundle:nil];
    subCat.getCatVal=[sender tag];
    [self.navigationController pushViewController:subCat animated:YES];

// this would assign the tag to the next page getCatVal variable.

Wanna use selecto to call that you can write:-

 UIButton *btnImage2=[UIButton buttonWithType:UIButtonTypeCustom];
 [btnImage2 addTarget:self action:@selector(Click:)forControlEvents:UIControlEventTouchUpInside];