开发者

Tableview refreshing to parent view after selecting child using reload data

I have a UITableView that uses JSON to to get new data from the AppDelegate. It saves the data and then is pulled into th开发者_开发技巧is tableview class from the AppDelegate.data3, After I add a record to the mysql database I launch the Delegate method that refreshes the data.

However,[self.tableview reLoadData]; breaks the drill down ability of the table, If I select the row, it pushes the child view for a split second and the refreshes the screen with the Parent Rows. If I take out the [self.tableview reLoadData]; The parent pushes to the child but I don't get a refreshed screen with the new data.

Any Ideas?

-(void) loadData3;{

    //Initialize table data source  
    MyAppDelegate *AppDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
    self.tableDataSource3 = [AppDelegate.data3 objectForKey:@"Rows"];

}
  - (void)viewDidLoad {
    [super viewDidLoad];
    if(CurrentLevel3 == 0) {
        self.navigationItem.title = @"Parent Table";
     }
    else 
        self.navigationItem.title = CurrentTitle3;  
     }
 }
- (void)viewDidAppear:(BOOL)animated {
        [self loadData3];
        [self.tableview reloadData];
            [super viewDidAppear:animated];
        }


There are several issues. It's not clear what you are trying to do.

You set self.tableDataSource3 to tempArray, and then set it to [AppDelegate.data3 ....];

Why?

     NSArray *tempArray = [[NSArray alloc] init];
     self.tableDataSource3 = tempArray;
      [tempArray release];
    MyAppDelegate *AppDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
    self.tableDataSource3 = [AppDelegate.data3 objectForKey:@"Rows"];

On Startup [self loadData3] gets called twice. Once in viewDidLoad and viewDidAppear. Unnecessary. Should only be in viewWillAppear.

You're either not saving data that you're adding, or not retrieving it properly. Might have to step through your code to see if you're getting the data you should be getting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜