I create a UITableViewController's subclass:
class BaseTableViewController: UITableViewController {
var negozio : negozioAttivo?
}
Then , I created a BaseTableViewController's subclass
class offerteTableViewController: BaseTableViewController{
private var offerte : Array<offerta>?
private var cellIdentificatior : String = "Cell"
override func viewDidLoad() {
super.viewDidLoad()
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return (self.offerte)!.count
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return CGFloat(220)
}
override func viewWillAppear(animated: Bool) {
self.offerte = Database.getOfferteNegozio(1)
}
override var description: String {
return "Offerte"
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier(self.cellIdentificatior) as? TableCellSex
if (cell == nil ) {
var shop : negozioAttivo = self.negozio!
var id : Int = shop.id
var fotoPrinci : foto = shop.getPhoto(1)
var image : UIImage = fotoPrinci.downloadImage()!
cell = TableCellSex(text: shop.nome, image: image, id: self.cellIdentificatior, style: UITableViewCellStyle.Default,width: 150, height: 250 , star: Int(3) , distanza : "1km" , showHeart: true , male: shop.uomo == false , female: shop.donna == false)
}
return cell!
}
}
Then I created a UITableView
in StoryBoard and I give it the type of offerteTableViewController
, but when I execute it I get this:
the first cell is too above and goes off the screen ( in fact the picture is not seen completely)
答案 0 :(得分:0)
If your navigationVC has a translucent navigation bar and you want to tableview to be visible under the navigation bar when you scroll, then in your Storyboard, check the "Under Top Bars" which means you want the VC to scroll underneath the navigation bar and also check "Adjust Scroll View Inset" so that the scroll start below the navigation bar.
More detailed explanation can be found here: Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7
Note that this only works if your tableViewController is the rootView of your navigationVC.
In the special case of navVC -> PageVC ->TableVC add this to your tableview viewWillAppear
self.tableView.contentInset = UIEdgeInsetsMake(CGRectGetMaxY(self.navigationController.navigationBar.frame), 0,0,0);
if(self.tableView.contentOffset.y == 0 ){
self.tableView.contentOffset = CGPointMake(0, -CGRectGetMaxY(self.navigationController.navigationBar.frame));
}
答案 1 :(得分:0)
This sounds like your navbar is overlapping with your tableview. You could set the contentInsets of your tableView so that it starts offset from the top
self.tableView.contentInset = UIEdgeInsetsMake(64,0,0,0);
or try setting your navigation bar navigationBar.translucent = NO;
if it is set to yes.