2016-05-13 3 views
0

UITabelViewとの異なるviewのボタンを調整する移動可能な行があります。 行を移動すると、viewのアイコンが更新されます。 ([self refreshicons]に気づく)以下を参照してください:UIButtonとUILabelがビューの外でUIButtonから更新されていない

-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{ 
    NSInteger sourceRow = sourceIndexPath.row; 
    NSInteger destRow = destinationIndexPath.row; 
    id object = [shortcutApps objectAtIndex:sourceRow]; 

    [shortcutApps removeObjectAtIndex:sourceRow]; 
    [shortcutApps insertObject:object atIndex:destRow]; 
    [tableView reloadData]; 
    [self refreshIcons]; 

    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; 
    [userDefaults setObject:shortcutApps forKey:@"ShortcutArray"]; 
} 

これは[self refreshicons]

-(void)refreshIcons{ 
icon1 = [shortcutApps objectAtIndex:0]; 
NSLog(@"%@",icon1); 
[extraIcon1 setImage:[UIImage imageNamed:[[icon1 lowercaseString] stringByReplacingOccurrencesOfString:@" " withString:@""]] forState:UIControlStateNormal]; 
extraIconLabel1.text = icon1; 
NSLog(@"%@",extraIconLabel1); 
} 

あるNSLogsは、正しい文字列を印刷しますが、UILabelのとUIButton画像が更新されていません。アイコンが同じviewにある[self refreshicons]と同じコードを実行するボタンを作成すると、コードは必要に応じて機能します。しかし、行が移動されたり、ボタンがボタンの外側に押されたりすると、ラベルとボタンは更新されません。view 考えますか?

+0

あなたはより良いアイデアを得るためにいくつかのスクリーンショットを投稿できます – harshitgupta

+0

なぜ 'reloadData'を' moveRowAtIndexPath: 'メソッドから呼び出すのですか? – rmaddy

+0

@rmaddy私のテーブルビューには、インデックス番号に応じて色を変更する必要がある行があるため、 – Manesh

答えて

0

tableview:cellForRowAtIndexPath:メソッドで何が起きていても、アイコンが無効になっているようです。

refreshIconsの参照値はすぐに値を更新するために参考にしておいたコンセントですが、reloadDataサイクルを通過している可能性があります。

+0

私はUITableViewと同じUIViewにボタンを追加しましたが、Iconsはまだ表示する必要がある画像/テキストに更新されていません。リフレッシュが必要なボタンは、UIScrollViewにあります。不思議なことに、NSLogはラベルLabelを更新されたラベルに表示しますが、Label自体は更新されません。 – Manesh

関連する問題