2011-05-11 10 views
0

私は自分のアプリケーションでUITable Viewを使用する必要があり、それは風景とポートレートの両方向をサポートしなければなりません。プログラムでテーブルビューを作成するには?

私が直接、私は正確に

その後、私はプログラム的に同じことを示唆していた場合は、それを制御することができますどのようにインターフェイスビルダーからのUITableViewドラッグした場合。

おかげ Rizwan

+0

は以前anwersを受け入れるようにしてみてください – Aravindhan

答えて

0
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
     return 1;//Returns the no of sections in the tableview 
    } 

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
     return 5;//Returns the no of rows in the tableview 
    } 

//This method is called everytime when a row is created. 
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

     static NSString *CellIdentifier = @"Cell"; 

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

     if (cell == nil) { 

      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 

     } 

     // Configure the cell... 
     cell.textLabel.text [email protected]"tableview"; 

     return cell; 

    } 
関連する問題