ショップでアイテムが売れるようになった。自分のアイテムのinfoも見れるようなった。UITableViewCellでaccessoryViewというのにボタンを指定するだけ。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
....
UIButton *anAccessory = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *aImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"icon_info" ofType:@"png"]];
[anAccessory setBackgroundImage:aImage forState:UIControlStateNormal];
anAccessory.frame = CGRectMake(0, 0, 24, 24);
anAccessory.showsTouchWhenHighlighted = YES;
[anAccessory addTarget:self action:@selector(tappedAccessory:withEvent:) forControlEvents:UIControlEventTouchUpInside];
anAccessory.userInteractionEnabled = YES;
cell.accessoryView = anAccessory;
- (void)tappedAccessory:(UIControl *)button withEvent:(UIEvent *)event{
NSIndexPath *indexPath = [self.theTableView indexPathForRowAtPoint: [[[event touchesForView: button] anyObject] locationInView: self.theTableView]];
NSLog(@"%i", indexPath.row);
}
No comments:
Post a Comment