2009-01-24 2 views

답변

7

설정 데이터 소스 및 클래스 3 방법에서 정의

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

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *cellId = @"identifier"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: cellId]; 
    if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellId] autorelease]; 
    } 
    [cell setText:[NSString stringWithFormat:@"e%i",indexPath:[indexPath row]]; 
    return cell; 
} 
0

jQuery과 공부를 보상 구성 요소입니다. UITableView 및 해당 데이터 소스 및 위임 프로토콜에 대한 로컬 문서 페이지를 읽습니다. 문서에도 테이블 뷰 프로그래밍 가이드가 있습니다. 그것은 좋은 읽을 거리입니다. 그 중 일부는 나에게 잠시 걸렸고, 구현할 때마다 여전히 접근 방식을 수정하고 있습니다. API를 사용하고 필요한 방법을 구현하면 자신의 의지대로 구부릴 수 있어야합니다.

Hellra1ser의 예는 올바른 방향으로 사용자를 밀어 넣습니다. 먼저 해당 방법을 찾아보십시오. 많이 사용하게 될 것입니다. 빠른 3.1

0

코드 :

그냥 사람이 테스트의 목적을 위해 붙여 복사 할 필요가있는 경우 경우이다.

extension ViewController : UITableViewDataSource, UITableViewDelegate { 
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
     return 50 
    } 
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) 
     cell.textLabel?.text = "Test" 
     return cell 
    } 
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 
     return 60 
    } 
} 
관련 문제