displaying a navigation bar over a UITableView.

Ok so i've implimented a UITable view to load an RSS feed, the problem is that im unable to add a Navigation bar floating over the TableView like i am doing in other views. can anyone guide me in this area? i'm also wanting to avoid doing things that cause more prosessing or bugs on the users end.


import UIKit
import SafariServices
import TIFeedParser
import Alamofire

class Listen: UITableViewController {
    @IBOutlet weak var WOLMenu: UIBarButtonItem!
    
    var items : Array = []
    var entries : Array = []
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        loadRSS()
        loadAtom()
        
        WOLMenu.target = self.revealViewController()
        WOLMenu.action = #selector(SWRevealViewController.revealToggle(_:))
        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())

    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return items.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "ItemCell", for: indexPath)
        
        let item:Item = self.items[indexPath.row]
        cell.textLabel?.text = item.title
        cell.detailTextLabel?.text = self.pubDateStringFromDate(item.pubDate! as Date)
        
        return cell
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        let item = self.items[indexPath.row]
        
        let url:URL = URL(string: item.link!)!
        let safariViewController = SFSafariViewController(url: url, entersReaderIfAvailable: true)
        present(safariViewController, animated: true, completion: nil)
    }
    
    func loadRSS() {
        
        let feedUrlString:String = "https://vimeo.com/hidden/videos/rss"
        
        Alamofire.request(feedUrlString).response { response in
            
            if let data = response.data, let _ = String(data: data, encoding: .utf8) {
                
                TIFeedParser.parseRSS(xmlData: data as NSData, completionHandler: {(isSuccess, channel, error) -> Void in
                    
                    if (isSuccess) {
                        self.items = channel!.items!
                        self.tableView.reloadData()
                    }
                    
                    if (response.error != nil) {
                        print((response.error?.localizedDescription)! as String)
                    }
                })
            }
        }
        
    }
    
    func loadAtom() {
        
        let feedUrlString:String = "https://vimeo.com/hidden/videos/rss"
        
        Alamofire.request(feedUrlString).response { response in
            
            if let data = response.data, let _ = String(data: data, encoding: .utf8) {
                
                TIFeedParser.parseAtom(xmlData: data as NSData, completionHandler: {(isSuccess, feed, error) -> Void in
                    
                    if (isSuccess) {
                        self.entries = feed!.entries!
                        self.tableView.reloadData()
                    }
                    
                    if (error != nil) {
                        print((error?.localizedDescription)! as String)
                    }
                })
            }
        }
    }
    
    func pubDateStringFromDate(_ pubDate:Date)->String {
        let format = DateFormatter()
        format.dateFormat = "yyyy/M/d HH:mm"
        
        let pubDateString = format.string(from: pubDate)
        return pubDateString
    }
    
    override var prefersStatusBarHidden: Bool {
        return true
    }
    

}
https://ibb.co/8g8Z2k9

https://ibb.co/8g8Z2k9 storyboard view


the current code runs well, however the navigation bar does not float. So what should i impliment to acheave this, how much code will need to change (i assume ill be changing the structure sadly)

Replies

What do you expect exactly by Navigation bar floating over the TableView ?


If I understand your intent, you should probably reduce the tableView size at the top to make room for navigation bar.