2014-01-30 3 views
0

안녕을 치면있는 UITableViewCell에 UITextfields을 표시하는 방법 내가 UITableviewcell 세의 "+"기호를 클릭하면됩니다 나는 UITableviewCell이 있고 나는 UITableviewcell 누군 요구 사항의 끝 부분에있는 "+"기호를 넣어 UITextfields는 다음에 표시됩니다 UITableviewcell. 그리고 또한 처음에는 UITableviewcell에 3 UITextfields을 표시하고 싶습니다. 그리고 "+"기호는 모두 tableview에 표시됩니다. 그러나 "+"기호를 동적으로 표시하려고합니다. 어떻게하면 도움이 될 수 있습니다. 이것은 내 코드입니다.사용자가 "플러스"기호

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 3; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return 3; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *cellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

    if (!cell) 
    { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier]; 
    } 
    [cell.textLabel setText:@""]; 
    UIButton *myGreenIconButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [myGreenIconButton addTarget:self action:@selector(GreenIconButtonClicked:)forControlEvents:UIControlEventTouchUpInside]; 
    [myGreenIconButton setBackgroundImage:[UIImage imageNamed:@"index.jpg"] forState:UIControlStateNormal]; 
    myGreenIconButton.backgroundColor = [UIColor clearColor]; 
    myGreenIconButton.frame = CGRectMake(285, 28, 25, 25); 
    [cell addSubview:myGreenIconButton]; 
    return cell; 
} 
+0

제발 부탁드립니다. –

답변

0

섹션을 하나 또는 그 이상으로 3 행으로, 각 행은 하나의 UITextfield을 가지며, 더하기 버튼을 치면 no. 섹션이 1 인 경우 UITableview[tableview reloaddata];을 사용하여 다시로드하십시오.

이전에 각 섹션의 하단에 + 버튼 용으로 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section- (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section과 같은 대리인 메소드를 추가해야합니다.

각 섹션에 꼬리말보기를 추가하는 방법은 this question을 참조하십시오.

Table with UITextField an UIImage 는 그런 다음 태그로이를 사용할 수 있습니다

+0

답장을 보내 주셔서 감사합니다.하지만 이해할 수 없습니다. 자세한 정보 나 제 코드를 기반으로 한 사례를 알려주십시오. – user3252427

+0

자세한 내용은 myGreenIconButton이란 무엇입니까? 버튼을 클릭하면 어떻게 될까요? + 버튼을 어디에 표시해야합니까? 모든 행에? 귀하의 답변에 대해 – NAZIK

+0

@ 감사합니다. "myGreenIconButton"은 UIButton 객체 이름입니다. "+"버튼을 클릭하면 세 개의 UITextfield가 다음 UITableviewcell에 표시됩니다. 모든 uitableviewcell의 끝에 + 버튼을 배치하고 싶습니다. – user3252427

0

더 내 화면처럼 엑스 코드의 첫 번째 표 안에 당신이 원하는 것을 수동으로 삽입 할 수 있습니다 DB를 또는 설치 동적 테이블에 PLIST 파일을 사용되지만, :

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
    } 

UIImageView *logoImageView = (UIImageView *)[cell viewWithTag:1]; 
     logoImageView.image = [self.cachedImages valueForKey:identifier]; 

UILabel *detailLabel = (UILabel *)[cell viewWithTag:2]; 
    detailLabel.text = (self.loadImage)[indexPath.row][@"subtitle"]; 
} 

인터페이스에 태그를 설정, 개체를 선택하고 속성 관리자에 이동 :

enter image description here

UITableView and Plist tutorial

희망 : 테이블 부하가 동적으로 이미지 또는 텍스트를 얻을 때 당신은 UITableView 튜토리얼 plist 플러스를 볼 수 있습니다

, 여기

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
} 

사용하여 DetailViewController이 정보를 파하기 도와 드리겠습니다.