2013-05-13 3 views
0

"버튼을 채우려면 누르십시오." 테이블 뷰를 탭하면 옵션이 표시됩니다. 이러한 옵션을 버튼에 연결하여 "채우기 탭"이 사용자가 선택한 데이터/행으로 대체되도록하려면 어떻게해야합니까? 나는 어디서부터 시작해야할지 전혀 모른다. 미리 감사한다.표보기 셀을 선택할 때 버튼의 제목을 변경하십시오.

답변

0

이 시도 :

- (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath { 
    NSUInteger row = [indexPath row]; 
    NSString *newText = [youArray objectAtIndex:row]; //yourArray contains your datas (of type NSString in this example) 

    //consider your button btn is an inst var 
    [btn setTitle:newText forState:UIControlStateNormal]; 
} 
+0

안녕하세요. 답장을 보내 주셔서 감사합니다. 나는 네가 제안한 것을했지만 내 버튼은 필드를 업데이트하는 것 같지 않아 .. 좀 더 구체적으로 좀 해주실 수 있겠 니? 미리 감사드립니다. – Torylon

+0

내 배열 : NSArray * array = [[NSArray alloc] initWithObjects : @ "1", @ "2", @ "3", @ "4", nil]; \t self.tableViewArray = array; – Torylon

+0

테이블 뷰 코드 : - (NSInteger) tableView : (UITableView *) tableView numberOfRowsInSection : (NSInteger) 섹션 { \t return [tableViewArray count]; } - (있는 UITableViewCell *)를 tableView (jQuery과 *)를 tableView cellForRowAtIndexPath (NSIndexPath *) indexPath { \t \t있는 UITableViewCell * 셀 =있는 tableView dequeueReusableCellWithIdentifier "SimpleTableIdentifier"@]; \t if (cell == nil) { \t \t cell = [[UITableViewCell alloc] initWithStyle : UITableViewCellStyleSubtitle reuseIdentifier : @ "SimpleTableIdentifier"]; \t} \t \t cell.textLabel.text = [tableViewArray objectAtIndex : indexPath.row]; \t \t 복귀 셀; } – Torylon

0

// 버튼 팝업 .H 파일의 ViewController에서 다음과 같은 속성을 만들 버튼 클릭에

@property (strong, nonatomic) UIButton *button; 

// 호출 팝업보기를 클릭

을 다음과 같이
YourTableViewController *tables = [UITableviewController alloc] init]; 
tables.button = buttonObjectWhoesTextYouWantToChange; 
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:tables]; 
popover.delegate = self; 
popover.popoverContentSize=CGSizeMake(280.0, 327.0); 

// 이제이 단일 행을 tableviewcontroller의 didSelectRowAtIndexPath 메서드에 추가하십시오.

self.button.text = cell.textLabel.text; 
관련 문제