사용자 지정 셀이있는 테이블 뷰가 있습니다. 셀 내부에 가로로 스크롤되는 스크롤 뷰가있는 셀 내부 테이블 뷰 셀에 버튼이 추가되었지만 터치로 버튼이 응답하지 않음 스크롤 뷰에 버튼이 추가되지 않았습니다 .On 이 버튼 클릭, 내 임무는 다음 버튼처럼 뒤에있는 스크롤 뷰의 오프셋을 변경하는 것입니다. 터치를 어떻게 감지 할 수 있습니까? 이것은 스크롤 뷰에 내용을 추가하는 코드입니다.
for(int i=0;i<[exerciseArrayForeachSection count];i++){
Exercise *data = [exerciseArrayForeachSection objectAtIndex:i];
[_customCell.exTitleLabel setText:data.exName];
if([data.exImage length] < 1){
[[AsyncImageLoader sharedLoader] cancelLoadingURL:_customCell.exThumbImageView.imageURL];
}
else if ([data.exImage length] > 0)
{
int intExerId = [data.exImage intValue];
NSString *fullPathString = [NSString stringWithFormat:@"%@%d/%@",EXER_URL,intExerId,data.exImage];
NSURL* aURL = [NSURL URLWithString:fullPathString];
_customCell.exThumbImageView.imageURL = aURL;
imageUrlDetails=fullPathString;
}
[_customCell.scroll addSubview:_customCell.excerciseDetailsView];
_customCell.scroll.contentOffset=CGPointMake(_customCell.scroll.contentOffset.x+320, _customCell.scroll.contentOffset.y);
}
[_customCell addSubview:_customCell.scroll];
[_customCell.scroll bringSubviewToFront:_customCell.nextBtn];
}
버튼 클릭에 대한 메서드는 다음과 같은 사용자 지정 셀보기에서 호출됩니다.
-(IBAction)nextClickActn:(id)sender{
[[self delegate]nextButtonAction:self];}
그리고 테이블 뷰 컨트롤러에서
- (void) nextButtonAction:(id)sender {
UITableViewCell *cell = (UITableViewCell *)sender;
_customCell=(CustomCellFor_Dashboard*)cell;
if ( _customCell.scroll.contentOffset.x <= _customCell.scroll.contentSize.width ) {
CGRect frame;
frame.origin.x = _customCell.scroll.contentOffset.x +_customCell.scroll.frame.size.width;
frame.origin.y = 0;
frame.size = _customCell.scroll.frame.size;
[_customCell.scroll scrollRectToVisible:frame animated:YES];
// pageControlBeingUsed = YES;
}
}
이것을 시도하고 이것을 cellForRowAtIndexPath 메소드에 구현하십시오.
UIButton *accessoryView = [[UIButton alloc] initWithFrame:CGRectMake(190, 5, 40, 41)];
accessoryView.tag = indexPath.row;
[accessoryView addTarget: self action:@selector(yourMethodWhichUWantToCall:)forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = accessoryView;
그런 다음 해당 메서드에서 다음 코드를 구현합니다.
UIButton *accessoryView = (UIButton *)sender;
UITableViewCell *cell;
if(isIOS7)
{
cell = (UITableViewCell *)accessoryView.superview.superview;
}
else
{
cell = (UITableViewCell *)accessoryView.superview;
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다