我的UITableView
内部有一个UIViewController
. 数据、字幕数据和附件按钮都加载正常;但是,当我按下任何附件按钮时,它们都返回索引 0?
dataSource
并delegate
连接到 .xib 中的文件所有者我错过了什么?
头文件:
@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
实施,我的cellForRowAtIndexPath:
(按钮部分):
@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;
我的buttonPressed
方法:
- (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;
}
所有这些代码都适用于我的其他专用UITableView
页面。