2012-03-02 6 views
0

私はカスタム表の行を持つUITableViewを持っています。私が必要とするのは、行を並べ替える可能性を持つことです。また、次のメソッドを追加iPhone:UITableViewの並べ替えの行ボタン

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [self.myTableView setEditing: YES animated: YES]; 
} 

を::

- (BOOL)tableView:(UITableView *)tableView 
    canEditRowAtIndexPath:(NSIndexPath *)indexPath { 
    return YES; 
} 


- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView 
    editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 
    return UITableViewCellEditingStyleNone; 
} 


- (BOOL)tableView:(UITableView *)tableView 
    shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath { 
    return NO; 
} 


    - (BOOL)tableView:(UITableView *)tableView 
    canMoveRowAtIndexPath:(NSIndexPath *)indexPath { 
    return YES; 
} 

はまた、私は私のカスタム・テーブルの行のためのBGの色を設定しますので、のviewDidLoadで、私は追加

- (UITableViewCell *)tableView:(UITableView *)tableView 
    cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
NSString *customTableRow = @"customTableRow"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: 
    customTableRow]; 
if (cell == nil) { 
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"customTableRow" 
     owner:self options:nil]; 
    if (nib.count > 0) { 
     cell = self.customTableRow; 
    } 
} 
cell.contentView.backgroundColor = [UIColor colorWithRed:(228.0f/255.0f) 
    green:237.0f/255.0f blue:244.0f/255.0f alpha:1.0]; 
return cell; 
} 

そして私は私のアプリを実行し、予期せぬ見解がありました:

enter image description here

私はトウの質問があります: 1.それはなぜそうですか?並べ替えボタンは透明ではありませんか?
2.ボタンを自分の画像に変更する方法は?

答えて

1

問題はcontentViewの背景色を変更していることです。 -tableView:willDisplayCell: forRowAtIndexPath:でセル自体の背景色を変更しようとしましたか?

+0

私はしませんでしたが、私はします。質問番号2はどうですか? – Jim

+0

あなたはおそらく、セルのサブビューを反復してボタンをあなたのものに置き換えることができますか? –

+0

Alexsander、申し訳ありませんが、セルの背景色を変更すると(コンテンツビューではなく)セルに目に見える影響はありません。また、並べ替えコントロールはセルのサブビューに含まれません。 – Sagiftw

関連する問題