가능한 중복있는 tableView 셀 버튼 이미지를 변경하려면 다음어떻게 IOS에서 클릭에
how to change tableView Cell button on click in iphone
나는 배경 이미지와 테이블 뷰 셀에 버튼이 기능을 사용하여 설정해야합니다. 도청 버튼에 대한
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
SectionsTableIdentifier];
cell.textLabel.text = self.names[self.keys];
if (cell.accessoryView == nil) {
UIImage *buttonUpImage = [UIImage imageNamed:@"button_up.png"];
UIImage *buttonDownImage = [UIImage imageNamed:@"button_down.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:buttonUpImage
forState:UIControlStateNormal];
[button setBackgroundImage:buttonDownImage
forState:UIControlStateHighlighted];
[button setTitle:@"Send" forState:UIControlStateNormal];
[button sizeToFit];
[button addTarget:self
action:@selector(tappedButton:)
forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = button;
}
return cell;
}
코드입니다 : 내가 필요로 이제
- (void)tappedButton:(UIButton *)sender
{
NSInteger row = sender.tag;
// NSString *character = self.names[self.keys];
/* NSString *key = self.keys[indexPath.row];
NSArray *nameSection = self.names[key];
NSString *character = nameSection[indexPath];
*/
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Request Notification."
message:[NSString
stringWithFormat:@"Friend Request Sent ."]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
/* UIImage *buttonUpImage = [UIImage imageNamed:@"button.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[cell.theSyncButton setImage:buttonUpImage forState:UIControlStateSelected];
[button setBackgroundImage:buttonUpImage
forState:UIControlStateNormal];
[button setTitle:@"Sent" forState:UIControlStateNormal];
[button sizeToFit];
*/
}
배경 색상과 제목을 변경하는 것입니다
동적에 사용자가 클릭이 테이블 뷰 셀에 '보내기'버튼을 때 "전송"을 괜찮나 전 이 기능을 사용할 수 있습니까? 버튼을 전달받을 tappedButton 당신의 IBAction를 방법에
변경 버튼 배경 이미지 :'['사용 발신자 setBackgroundImage : buttonUpImage forState : UIControlStateNormal]' – Akhilrajtr
[보낸 사람 setImage : buttonUpImage forState : UIControlStateSelected]; 여전히 작동하지 않습니다. – user3482051
이미지를 설정 한 후'reloadRowsAtIndexPaths :'메소드로 셀을 다시로드하십시오. – Akhilrajtr