I have a UITableView
inside my UIViewController
. Data, subtitle data and and accessory buttons all load fine; however, when I press any accessory button they all return index 0?
dataSource
and delegate
are wired to File's Owner in the .xib What am I missing?
Header file:
@interface OrderPage : UIViewController <UITableViewDataSource, UITableViewDelegate> {
NSDictionary *userOrderData;
NSMutableArray *myMasterList;
UITableView *tableView;
NSMutableArray *contentss;
NSMutableArray *mysendArray;
NSDictionary *my_data;
}
-(IBAction)sendOrders;
@property( nonatomic, retain) NSDictionary *userOrderData;
@property ( nonatomic, retain) IBOutlet UILabel *firstOrder;
@property(nonatomic, retain) NSMutableArray *myMasterList;
@property(nonatomic, retain) UITableView *tableView;
@property(nonatomic, retain) NSMutableArray *contentss;
@property(nonatomic, retain) NSMutableArray *mysendArray;
@property(nonatomic, retain) NSDictionary *my_data;
@end
Implementation, my cellForRowAtIndexPath:
(button section):
@synthesize tableView = _tableView;
UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
button.tag = indexPath.row;
[button addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
button.backgroundColor = [UIColor clearColor];
cell.accessoryView = button;
My buttonPressed
method:
- (void)checkButtonTapped:(UIButton *)sender {
UITableViewCell *cell = ((UITableViewCell *)[sender superview]);
NSLog(@"cell row: int%i", [self.tableView indexPathForCell:cell].row);
NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]];
NSLog(@"The row id is %d", indexPath.row);
UIImageView *btnCliked =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark.png"]];
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[activityView startAnimating];
cell.accessoryView = btnCliked;
}
All of this code works on my other dedicated UITableView
pages.