0

I am using xcode6.3

I created a array in the SimpleViewTable.m file

tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil];

When i run the program.

In the simulator screen i got result but it start from the @"Vegetable Curry".

It is not showing result from index 0.

When i click on the table item and drag down, then i see previous items. and it again moves up.

Please give me a suggestion so that i can resolve this issue.

Dhaiyur
  • 98
  • 9
Sunny Patial
  • 379
  • 1
  • 3
  • 14
  • can u perform this action of initializing the array and throw again the feedback what happened? tableData= [[NSArray alloc]initWithObjects:@"A",@"B", nil] – Rajan Maheshwari Apr 22 '15 at 11:46
  • Do you use a UIViewController containing a UITableView or did you use a complete UITableViewController? Also, do you use some HeaderViews for the Table? – itinance Apr 22 '15 at 11:46
  • @Rajan, i tried with [[NSArray alloc]initWithObjects.... but i am getting same issue. – Sunny Patial Apr 22 '15 at 14:16
  • @itinance, i used UITableView to display a products list, present in the array. – Sunny Patial Apr 22 '15 at 14:18

2 Answers2

0

As you mentioned that when you drag down the table view, you are able to see the index 0 record and then it again goes in hiding state; indicates that there is something wrong with either contentOffset or contentInset of table view. Keep a break point in viewDidAppear: and check if contentOffset is set to a non-zero value. Reset it to zero if as given below. Same goes for contentInset property

self.tableView.contentOffset = CGPointMake(0, 0);// If class is child of UITableViewController
[self.tableView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];

OR

objTableView.contentOffset = CGPointMake(0, 44);// If you are using a UITableView object explicitly
[objTableView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
Gandalf
  • 2,399
  • 2
  • 15
  • 19
  • Hi Gandalf, thanks for your response.. could you please guide me how can i set contentInset and contentOffset to 0 – Sunny Patial Apr 22 '15 at 14:19
  • Check the edited answer, but first ensure that your `contentOffset` indeed is coming as non-zero. This is the pretty obvious cause but there can be something else wrong in the code. – Gandalf Apr 22 '15 at 17:36
0
  • Yes, we have got the same issue and found solution on it. You need to reload your tableview twice:-

    See below code for example:-

    [tableview reloadData];

    [self performSelector:@selector(refreshData) withObject:nil afterDelay:0.0];

    -(void)refreshData { [tableview reloadData]; }