Open DinosMa opened 7 years ago
Did you set the tableview's delegate and dataSource to your list view controller?
yes to both Controllers menu Controller List View Controller - which is the main
when you tap on the menu it saw all the categories, when you tap then to random category .. it loads the main feeds and not the category feeds
Sorry, I understood that your categories was not show in your table view!
In didSelectRowAt, you instantiate SWRevealViewController (which is already instantiated), then this new instance of SWRevealViewController show the front view controller...
If you want to show another view controller you have to instantiate and push it with SWRevealViewController:
let controller = storyboard.instantiateViewController(withIdentifier: "YourController")
let nc = UINavigationController(rootViewController: controller)
revealViewController().pushMainViewController(nc, animated:true)
thanks but I get some errors
Sorry: pushFrontViewController (pushMainViewController is for my library!)
thanks again but it crash I am kind confused .. not so much experinece anyway,
should I use like both?
or to delete the first one anyway .. weird error
It is clear: Your controller in Main.storyboard does not have an identifier or it is not equal to "ListViewController":
Example:
You have to use only the 3 last lines of code.
thanks again it works but again it loads the main feeds and not the category feeds.. I think with the category_id might something might be wrong.. I dunno
Because you have to instantiate and push DetailViewController instead of ListViewController, no?
If you want you can share your project here and I will have a look.
yes .. thats the better thing to do I will share it as you might see there is also a other menu.. which I will delete it when I fix the SW the thing also is that the project is 52mb how to share it here?
Ah, you can use https://wetransfer.com/
patrick.bodet4@wanadoo.fr
Ok, got it
is kind messy project .. but is working .. let me know merci
When you select a category (feed) in left menu you want to show detail view controller. And where do you want to go back after? In ListViewController I suppose? You want the back button to go back to ListViewController?
the main scene of the app is the ListViewController.. so when you tap the left menu .. it should shows the feed of the categories in the ListViewController .. try to see how it works on the right menu
Ah you don't want to go directly to detail? You want to scroll the table view (ListViewController) as when you select on right menu?
yes .. thats what I am trying to do all this hours
also I will try to add a UIsearch in the top of the menu like this
ListViewController.swift:
func refresh(afterRefresh: (() -> Void)? = nil) {
reloadPosts(onLoad: {() -> Void in
self.refreshControl?.endRefreshing()
afterRefresh!() // Added completion handler call
})
}
MenuController.swift:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let menuList = menuLists[indexPath.row]
let revealViewController: SWRevealViewController = self.revealViewController()
let nc = revealViewController.frontViewController as? UINavigationController
let controller = nc?.topViewController as? ListViewController
controller?.category_id = menuList.id
controller?.refresh(afterRefresh: {() -> Void in
self.revealViewController().revealToggle(animated: true)
})
}
thanks .. I really appreciate it! it working one last thing is when you go to the category to flip back the menu
I don't understand your last question, sorry: "to flip back the menu"
ok .. mistake.. it was delay problem ... anyway thanks again .. for your help I need now to clean and update to Apple Store thanks
Yes I think it is too long. Do you need to reload from Internet each time?
You don't want to add your search bar before update to Apple Store?
For the delay to close the menu, I forgot the main queue: Add DispatchQueue.main.async to revealToggle
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let menuList = menuLists[indexPath.row]
let revealViewController: SWRevealViewController = self.revealViewController()
let nc = revealViewController.frontViewController as? UINavigationController
let controller = nc?.topViewController as? ListViewController
controller?.category_id = menuList.id
controller?.refresh(afterRefresh: {() -> Void in
DispatchQueue.main.async {
self.revealViewController().revealToggle(animated: true)
}
})
}
For your search bar:
And embed your MenuController in Navigation controller (uncheck "Shows Navigation Bar") in storyboard
hey thanks .. sorry for the delay i was out !! let me try them how to manage all this and then i have to ask one more last thing about the images ... in the deital view.. that it cut the images half from the article
I'am not a specialist of html but I think this is the server side responsibility. Or try with a Web View...
is it about html? I have put this `extension Data { var attributedString: NSAttributedString? { do { return try NSAttributedString(data: self, options:[NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: String.Encoding.utf8.rawValue], documentAttributes: nil) } catch let error as NSError { print(error.localizedDescription) } return nil } } it works but just cut the images !! hmm anyway in the next update i need to work for notifications and to put weather on nav ..
`
Είναι ωραίο σπίτι; Αγαπώ την Ελλάδα!
yeap we all do .. the weather and the sea ... not so much the rest so that why i am trying to learn swift and create apps so i can leave to go Holland as junior or medium iOS Developer as i saw you know python? this something that i have to learn also .. about Data Science, big data so are you in France? Paris?
I have cart an app news app and I am trying to make SWRevealViewController to work in the main controller (ListViewController - in my case). So far when I tap on the catogory on the menu it appears in the main Controller, but doesn't lead to any categories. It is obvious that something I have done wrong with the id.
`import UIKit
struct MenuList { var id: Int var title: String! }
class MenuController: UIViewController, UITableViewDelegate, UITableViewDataSource {
`