Correctly returning UIView in viewForHeaderInSection iOS 8 swift

I am fairly new to swift language and iOS development as a whole so please pardon me for my lack of fundamental knowledge. Previously i tried and successfully Implemented multiple sectioned UITableView custom sections by making a xib file creating TableViewCell and then loading it into my main ViewController and returning it as coded below:

But since i started getting "no index path for table cell being reused" i went back to drawing board and tried to do things programmatically creating a UIView and return it, so far i am have been unsuccessful however this is what i coded:

As you can see i am trying to create a layout where i want my label and button horizontally laid out but somehow logic is not working out i tried disabling autoresize constraints on view itself but that too did not worked too. Please Help!

You never added your label or button to "view". Also your sizes don't make sense -- you set the widths of the label and button to be 1/2 the width of the table view, but then in your constraints, you have 80 points worth of spaces, so that can't work. In any case, you should NOT set any frames when you use auto layout. Get rid of those, and add a vertical constraint to either the label or the button, and a layout option to align them vertically. Also, you need to add your label and button to your view (and do it before you add the constraints). Something like this should work,