0
좋아, 한 뷰 컨트롤러의 테이블 셀에 포함 된 이름을 다른 뷰 컨트롤러의 배열로 전달하고 싶습니다. 첫 번째 테이블의 셀에도 포함 된 단추를 통해이 작업을 수행하려고합니다.테이블 셀 버튼을 통해 다른 뷰로 셀 이름 전달하기
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// add "add" button
UIButton *addFriendButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
addFriendButton.frame = CGRectMake(250.0f, 5.0f, 75.0f, 30.0f);
[cell addSubview:addFriendButton];
[addFriendButton addTarget:self
action:@selector(addFriend:)
forControlEvents:UIControlEventTouchUpInside];
if(!cell)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [array objectAtIndex:indexPath.row];
return cell;
}
그리고 여기 버튼 방식이 설명 될 것이다 곳이다 : 여기서
테이블 셀이 설명되어 어디
- (IBAction)addFriend:(id)sender
{
NSLog(@"Add friend.");
}
제 뷰 컨트롤러의 이름 - 하 한 pass -는 ViewController이고, 두 번째 View Controller는 전달 된 정보를받는 MyMealViewController입니다. 전달 된 정보를 저장하려는 배열을 myMenuArray라고합니다.
기본적으로 모든 관련 정보입니다. 나에게서 필요한 추가 정보가 있거나 질문하는 내용에 대한 설명이 필요한 경우 - 내 질문에 답할 수 있도록 알려주십시오.
사용할 수 있습니다. 무슨 일 이니? 하나의 명백한 버그는 dequed 셀이 nil 인 경우 셀의 구성을 완료 한 후에 새 셀을 할당한다는 것입니다. dequeue 바로 아래로 셀 할당을 이동해야합니다. – combinatorial
버그를 지적 해 주셔서 감사합니다. 제안한대로 변경했습니다. 내 질문에 대해서는 : "작동하지 않는다"는 것이 아니라 버튼이 두드려지면 이름을 전달할 두 번째 코드 블록에서 "addFriend"액션을 구현하는 방법을 알아내는 데 필요한 지침이 필요하다는 것입니다. –