質問

I recently updated to Xcode 5 and when i run my application the UITableView appears to be empty:

Here is the code:

     - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
     {
           static NSString *CellIdentifier = @"Notes";
           UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
           id obj = [matchedObjects objectAtIndex:indexPath.row];

            if ([obj isKindOfClass:[Notes class]]) {
                     Notes *note = obj;
                     cell.textLabel.text = note.topic;
                     cell.detailTextLabel.text = note.subject;
                     cell.imageView.image = nil;
             }
             else
             {
                      Picture *picture = obj;
                      UIImage *image = [UIImage imageWithData:picture.image];
                      cell.textLabel.text = NSLocalizedString(@"Image", nil);
                      cell.imageView.image = image;
                      cell.detailTextLabel.text = picture.subject;
             }
             NSLog(@"Cell Text %@",cell.textLabel.text);

             return cell;
       } 

I already implemented:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 10;
}

The white space above appears to be the cells. I think it has something to do with iOS 7. This is worked in xcode 4.5 . Any help is appreciated...

役に立ちましたか?

解決 5

I had a view covering my UITableView. Thanks for everyone that helped!

他のヒント

Don't forget to implement tableview other 2 important delegates:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 10;
}

I had similar issue on a table showing different product IDs to be purchased. Same issue in the iOS simulator but everything works well on the actual device. Have you tested on your iPhone/iPad, also?

I also faced same issue UILabel in UITable do not get display but get display on click in IOS 7 (due to issue with background colour) and i found that

  1. The issue was with the default background colour of the cell.
  2. In Ios 6 and 5 it use to set black but in Ios 7 it is set to White.

So the solution is: [cell setBackgroundColor:[UIColor blackColor]]; or set Text colour other than white if you choose to keep your background colour white.

My Issue was :

My tableview's height was 0. Not sure y.

(I had my tableview in XIB)

But, I fixed it by manually setting it to some static size.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top