UIView in navigation controller goes upwards...? - iphone

i have attached as header one UIView(which has lot of buttons etc) in UITableViewController.i did not use table header.but when i scroll table view ,the header view (XIB file) goes upwards..can i stop it?

Don't create it inside the UITableViewController. Create it outside and then you should get the desired behavior.

Related

Is there a way to create a header for multiple View Controllers in xcode?

I need some help on creating a "Header" for multiple View Controllers without copy/pasting every time the line of code into the new view controller I create.
Something like creating a header in PHP and including it into the pages you want.
In the header I want to add custom text/data.
I tried creating a View on a single View Controller and then implementing that view on multiple storyboards, but it doesn't work and doubt that's the way of doing it.
I tried looking for something similar to what I needed but couldn't find it.
I am new to swift/xcode.
Thank you
Create subclass of UIView with nib.
When adding instance of this view to view controller, also create
constraints(or create them with interface builder).
Add setup
method that takes String argument and sets the label outlet.
If you meant header that will push all the view controller content down, that's hard to implement and I don't advice it.
I need some help on creating a "Header" for multiple View Controllers without copy/pasting every time the line of code into the new view controller I create.
There are at least three ways to do this:
Common view: Create a common view that you just add to each scene where you want the header displayed. RealNmae gives pretty good instructions for that, as does the possible duplicate that matt linked in a comment, so I won't try to describe that approach again.
Inheritance: Put the code to create the header in a view controller class that's otherwise empty. You might call it HeaderViewController or something like that. Then make all the view controller classes that need to display the header subclasses of that HeaderViewController class.
Containment: Create a container view controller that displays the header. Container view controllers can draw part of your UI, and then let a contained "child" view controller handle the rest. UINavigationController and UITabBarController are examples of container view controllers -- they draw a bar at the top or bottom of the screen that provides some functionality, and everything else gets drawn by the contained view controller(s).

How can I change Table View Controller's type to a regular View Controller?

I followed the "Storyboard tutorial" and made some Table View Controllers; now I want to change one of them to a regular View Controller.
Is there a way to do that without making a new one?
One option is to edit the storyboard file directly. Navigate to the Storyboard in Finder and open with any text editor. Find the view controller in question and change the node in the xml from tableViewController to viewController.
This saves the pain of having to recreate the view controller, which comes in handy when you have a lot of connections made. This also works the other way around. If you have a viewController that started out as a plain view controller but you want to turn it into a table view controller you can simply edit the file reversing the node.
You need to create a new view controller and drag a tableview into it. Remember to set the delegate and datasource of the tableview to the view controller.
I have had the same scenario where I needed to change the Tableviewcontroller to a view controller. I googled for a work around but ended up without an exact solution. What I did was added a subclass of view controller and dropped a UITableview and added some more controls that I wanted. Pretty inconvenient but worked the way eventually!

PullRefreshTableView editing

I have a PullRefreshTableView from leah(https://github.com/leah/PullToRefresh). Problem with this, as soon as I implement this. The view is changed to a tableview by doing this:
#interface news : PullRefreshTableViewController {
So I can't add any toolbars or navigationcontrollers to the top. Does someone know how I can add a toolbar to the top of the screen in combination with the PullRefreshTableView.
Thnx!
You know when you have this standard UINavigation template when you create a new project with xcode? Gives you 3 ( right ? ) nib files, 1 with the window, 1 with the mainview / navigation controller and the other one contains the tableview.
Open the one with the tableview. Select the tab that looks like this:
It will allow you to change the class it creates when the nib file is loaded. Change it to the PullRefreshTableView and when you launch the application a PullRefreshTableView will be created instead of a normal table view.
You can hook this up as an Interface Builder outlet exactly the same way you would hook up a normal table view. Its a subclass so it should even be able to be connected to the normal tableviewcontroller that is included in the template.
If you have done this, you should still be able to add the toolbars like you did with a normal table view. Also, if you want to have a toolbar on your iphone screen it shouldn't be a subview of the Tableview, but a container view should contain both the toolbar and the tableview.

How do I create a view with a picker on the bottom and a table view on the top?

first time asker, long-time lurker.
I am trying to create an iPhone view that has a date/time picker on the bottom half of the screen, and a grouped, single-section, four-row table view on the top half of the screen (almost identical to the one Apple shows in Fig. 2-4 of their View Controller Programming Guide (but then never goes on to explain).
Conceptually, I think I understand that what I need is a main view with a pair of subviews - one for the picker, and one for the table view. I'm pretty sure I can make the picker function once I have it on-screen, and I'm pretty sure I can make the table view function too. What I can't for the life of me figure out is how, programmatically speaking, to get the two views onto the screen simultaneously. I can lay it out perfectly in Interface Builder, but then it all goes to hell when I switch to Xcode...the view appears with the picker, but no table view.
Thanks, in advance, for any help you can offer.
the view appears with the picker, but no table view.
If the table view isn't assigned a data source, then it has nowhere from which to populate itself, and so it may give you the appearance of "not being there".
Have you created a view controller for this view? Is it a subclass of UITableViewController, or does it at least implement the UITableViewDelegate/UITableViewDataSource protocols? Is it set as the File's Owner in the .xib? And has it been assigned (using the connections) as your table view's delegate and dataSource?
In your .xib, are both the UITableView and the UIPickerView subviews of a top-level UIView, which is connected to your view controller's view property (i.e. for the File's Owner)?
UIView
+
|
+---UITableView
|
+---UIPickerView

iPhone: Image View and buttons under a TableView

Hi guys I have a table view but I don't want it to fill al the screen let's say I want it to be 320x420.
Well I want to put under the table view an image like a bar an image that would be 320x60.
The first time I tried this the image went down to the section footer of the table view and I wasn't able to see it until I get to the bottom of the table view.
After that I tried on the IB to resize the tableview and put under it the image, but when I tried it on the simulator the image didn't show up. I thought I was because the File's Owner view outlet was connected to the table view, so after that I disconnected with it and connected with the view that contained the table view, and when I tried in the simulator it crashed.
So I was looking on internet but still I can't find the answer. I don't know if you actually understood well my problem, cause my english kinda sucks.
Best Regards
Carlos Vargas
You don't need to connect the UIImageView to anything in the view. It will get loaded and placed automatically. The only reason you might want to connect it to anything is if you want to change something in it programmatically in the controller, and in that case you'd connect it to an IBOutlet in the controller.
I think what you need to do is create a UIView, then put the table view and the UIImageView inside the UIView. In IB it will look something like:
__
\/View UIView
Table View UITableView
Image UIImageView
You should be able to resize the subviews the way you want.
In the controller (File's Owner) make sure you have outlets for both View and Table View, then connect those views to the corresponding outlet. (Really you don't need to connect Table View to anything unless you need to directly configure it from the controller somehow. Setting the delegate and datasource properly should be enough.) Make sure to connect delegate and dataSource in the table view to the controller as usual. Make sure the view outlet in file's owner is connected to View and not TableView!
Your controller doesn't need to be a subclass of UITableViewController, it just needs to support the protocols. In fact, in this case using UITableViewController might not work because it may get "confused" if view is not set to a table view.
I just did this and it worked. In my case, though, I put an info button over the table view and did some other stuff.
Hope that helps.