0

独自のテーブルビューを持つ UITableViewController があります。しかし、データソースとデリゲートが別のクラスにある別の UITableView が必要です。

症状は次のとおりです。iPhone 4.0 では UITableView を表示できませんが、iPhone 6.0 シミュレーターではこの UITableView を正しく表示できます。

NSLog は、iPhone では UITableView の高さが 0.0 であることを教えてくれました。

問題は次のとおりです。2番目のUITableViewを取得します

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;`

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

何も反応がありません...

4

1 に答える 1

0

これを試すことができます。

UITableView の 2 つのオブジェクトを作成します。

numberOfRowsInSection 部分はこれを行います

  • (NSInteger)tableView:(UITableView *)tblView numberOfRowsInSection:(NSInteger)section {

    if (tableView == tblLog) 3 を返します。//または、それ以外の値は 2 を返します。}

CELLFORROWATINDEX 部分はこれを行います。

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

    UILabel *headingLabel;
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
        cell.backgroundColor = [UIColor whiteColor]; 
    }

    if(tableView == tblLog)
    {
        switch (indexPath.row)
        { 
            case 0:
            {
                //do something

            } break;

            case 1:
            {
               //do something

            } break;
        }

    }
    else if (tableView == tblRange)
    {
        switch (indexPath.row)
        { 
            case 0:
            {
                //do something
            }break;

            case 1:
            {
                //do something
            }break;
        }
    }

    return cell;
}

それが役立つかどうか教えてください

于 2012-10-25T07:28:27.413 に答える