Note that there are some explanatory texts on larger screens.

plurals
  1. POcall method from custom cell in iphone application
    primarykey
    data
    text
    <p>i have one view controller<br> Name : FirstVC </p> <p>i have table view in that view controller. in my table view i load a custom cell. in my custom cell there is 1 label and 1 button. i set label as well as button of custom cell from FirstVC. See bellow code.</p> <p>in FirstVC.h </p> <pre><code>@interface FirstVC : UIViewController &lt;UITableViewDataSource, UITableViewDelegate&gt; { IBOutlet UITableView *TblView; IBOutlet CustomCell *customCell; } - (void)addCounter:(NSInteger)pCat_ID; @end </code></pre> <p>in FirstVC.m </p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"Cell"; CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if(cell == nil){ [[NSBundle mainBundle] loadNibNamed:@"CustomCell_iPhone" owner:self options:nil]; cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; cell = categoryCustomCell; } NSInteger pCat_id = [[[arrayCategoryData objectAtIndex:indexPath.row] objectForKey:@"cat_id"] integerValue]; [customCell setTextForLable:@"Test"]; [customCell setAddCounterButton:pCat_id]; return cell; } - (void)addCounter:(NSInteger)pCat_ID { //Some code here…. } </code></pre> <p>in CustomCell.h </p> <pre><code>@interface CustomCell : UITableViewCell { IBOutlet UILabel *lblCategoryName; IBOutlet UIButton *btnAddCounter; } - (void)setTextForLable:(NSString *)cat_name; - (void)setAddCounterButton:(NSInteger)cat_ID; @end </code></pre> <p>in CustomCell.m </p> <pre><code>@implementation CustomCell - (void)setTextForLable:(NSString *)cat_name { lblCategoryName.text = cat_name; } - (void)setAddCounterButton:(NSInteger)cat_ID { [btnAddCounter addTarget:self action:@selector(addCounter:cat_ID) forControlEvents:UIControlEventTouchUpInside]; } @end </code></pre> <p>i want to call <strong>addCounter:(NSInteger)pCat_ID</strong> method from custom cell. but this idea can not worked. Please suggest me new idea.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload