Skip to content

Instantly share code, notes, and snippets.

View jeffcdavis's full-sized avatar
👨‍💻

Jeff Davis jeffcdavis

👨‍💻
View GitHub Profile
@jeffcdavis
jeffcdavis / menuTableViewController.swift
Last active August 10, 2016 18:27
Navigate to a view controller in the tab bar, from a SWRevealViewController menu
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let tabBarController = revealViewController().frontViewController as? UITabBarController
let navController = tabBarController?.viewControllers![indexPath.row] as? UINavigationController
navController?.popToRootViewControllerAnimated(true)
tabBarController!.selectedIndex = indexPath.row
revealViewController().pushFrontViewController(tabBarController,animated:true)
}
@jeffcdavis
jeffcdavis / menuTableViewController.swift
Last active August 10, 2016 21:23
If you need to get back to your tabbarcontroller from a view controller not connected to your tabbarcontroller, while using SWRevealController :)
// This assumes you want the first button in your tableview cells to go back to the tabbarcontroller
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if (indexPath.row == 0) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
// Give the tabbar an identifier in the storyboard
let targetViewController = storyboard.instantiateViewControllerWithIdentifier("myTabBarController") as! UITabBarController
targetViewController.selectedIndex = 0 // Your index you want to open
func UIColorFromHex(rgbValue:UInt32, alpha:Double=1.0)->UIColor {
let red = CGFloat((rgbValue & 0xFF0000) >> 16)/256.0
let green = CGFloat((rgbValue & 0xFF00) >> 8)/256.0
let blue = CGFloat(rgbValue & 0xFF)/256.0
return UIColor(red:red, green:green, blue:blue, alpha:CGFloat(alpha))
}
view.backgroundColor = UIColorFromHex(0x323232,alpha: 1)
@jeffcdavis
jeffcdavis / SearchController.php
Last active February 26, 2018 03:40
Laravel Registration Autocomplete text field
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Center;
class SearchController extends Controller {