how to add UIImageView overlay over a UITableViewController based controller? - iphone

How does one in XCode XIB builder add a UIImageView to an existing MasterViewController that has a TableView and is based on NavigationController?
Scenario
For example if you create a new project based on MasterDetail in XCode 4
Then look at the MasterViewController.xib file - so want to add a UIImageView to this that could be used to overtake the screen up until a point after which the image view is made hidden to disappear.
I'm trying to drag a UIImageView onto the page, and putting it just able TableView in the Objects column, however this doesn't work. Doesn't even show the image.
So even just knowing how to drag-drop an image onto the MastViewController.xib such that it takes over the screen at startup would be a step forward (not sure if I need a view to encapsulate both the UIImageView and the TableView?)
Background
Want to have an intermediate image that the iPhone app shows as it starts up
Idea would be start up (static) image is show, then straight away go to MasterViewController which would show this same static image with an activity indicator on it
Then when (is a background thread) the data preparation is down, the UIImageView could be made non-visible
PS. Some additional notes:
Initially there is just a table view you see in MasterViewController.xib.
If I drag an imageview in at the same level as the TableView it doesn't appear.
If I create a new view in the XIB and put the tableview and uiimageview under this, I get an error when running "'-[UITableViewController loadView] loaded the "MasterViewController" nib but didn't get a UITableView.'"

Is there a view or just a table view in your xib? If you want both a image view and a table view in the same view controller, you should have an ordinary UIViewController and let in implement UITableViewDelegate and UITableViewDataSource protocols and add a table view and a image view to its view.

so solved by:
creating a top level "view" in the XIB
put the UITableView & the new UIImageView under this new view
but, had to change the interface line to inherit from UIViewController NOT UITableViewController

Just add Default.png in resource.

Related

Set background image of a mutated TableViewController

I am working on a swift project in Xcode right now and one of my view controllers is a UITableViewController. I used swift to alter the size of the table view in the controller so that it does not fill up the entire screen. However, I want to set a background image for the entire view controller which I am unable to do since XCode is not letting me add an image view between the table view controller and the table view. Is there any way to do it using swift? Thank you.
I think I can help out.
If you're using Apple's UITableViewController - does that mean you altered the tableView's height in the storyboard? I think a better solution is to just use a regular UIViewController, add a tableView with whatever height you want it inside a UIViewController's view.
Often times I would recommend steering away from using Apple's custom things because you lose flexibility. Just make your own custom thing instead!
UIViewController > View > TableView & UIImageView
Make sure your tableview has a clear background!

Xcode 7 - custom UITableViewController no longer drawing in storyboard

I created a UITableViewController in my storyboard. Added all the table cells, etc. and set it up with a Custom UITableViewController. But now, when I open my Storyboard, the image of the ViewController no longer draws. There is a segue drawn from the calling controller, but it just points to empty space.
The original controller entry can be found on the left in the "document outline" with all of its subviews and constraints intact, and I can run the app on my iPad without a problem.
Has anyone seen this behavior before and is there a recovery action I can take to get the controller to draw in the storyboard?

Scene Dock in Apple's Date Cell Example?

I am looking at Apple's Date Cell (Date Cell Link) example project and I have a question about the Scene Dock in MyTableViewController. How come there are items extra items in the scene (Like Picker and Done) that are next to First Responder, Exit, and My Table View Controller? How can this be done? Also, how is this helpful?
This image shows the Scene Dock that I am referring to. Don't mind the titles, I renamed the project.
This image shows the Scene Outline for MyTableViewController, where the Picker and Done Button are shown next to the My Table View Controller, First Responder, and Exit and not within My Table View Controller.
This image shows an expanded outline for My Table View Controller where the Picker object is found also. But not Done Button is nowhere to be found inside My Table View Controller.
This image shows the code to connect to Picker and Done Button There is nothing special to this.
When I delete UIDatePicker in the scene of the controller (not in the cell), the inline DatePicker still works.
I think this sample is meant to support iOS 6.1 or earlier, to reveal the UIDatePicker as an external slide-in view, so it needs to be in the controller for IBOutlet connection.
Hope this will help.
Normally, the MyTableViewController should not be of type UITableViewController but its superclass UIViewController. This is normally necessary because UITableViewController has by definition its main view property set to the table view. It is then difficult to place other views into this view.
With a UIViewController, however, you can add any number of views. This is necessary in this case to accommodate the button and picker. The table view controller functionality can still be achieved by manually adding the UITableViewDataSource and UITableViewDelegate protocols and overriding the appropriate methods.
However, Apple here shows that it is possible by placing the other views on the same level as the main view, the table view. This is admittedly quite confusing. I usually prefer adding non-standard views as subviews to the view of a plain UIViewController.
You can drag things like picker views from the library to the scene dock to add them there.
As to the utility of doing this, I have no idea what that would be.
In this case I think that the picker and done button are left over from the writers of the code experimenting with ideas and forgetting to delete them. To verify that just delete the picker view and done button and see if everything still works.

UITableView with fixed image background

Sorry but I found no clear answer on that.
I have an iphone app with a tab bar and a UINavigationController in each tab.
The interface is built with Interface Builder, and in the first tab there is a UITableView.
I have prepared the xib with main view (A) containing a table (T) and an image (IMG) background behind (image as subview of main view).
Later I assigned UITableViewController as owner. This is where problems start.
In IB if I connect view to A I got a runtime error telling me that controller cannot find a table.
If I connect controller view to T everything works fine, except that IMG is not shown.
The only solution I found is to create a new xib holding A and IMG with a UIViewController as owner. Then create a xib holding T only and UITableViewController as owner, correctly connected to T.
Then in viewDidLoad of the UIViewController:
iptc = [[IPPlantsTableViewController alloc] initWithNibName:#"IPPlantsView" bundle:[NSBundle mainBundle]];
iptc.navigator=self.navigationController; // <-- need this
[self.view addSubview:iptc.view];
And this works, except that the table view seems to not know anything about navigationController, therefore detail view mechanism is not working, unless I set a property for it in UITableViewController.
I also run in to some other problems, for example all the logic for adding/deleting/creating rows to table has to be handled in UIViewController and sent to UITableViewController.
Is there another way for having a fixed image in a table view ?
Mmmm
I will be honest i HATE Interface Builder ;-) so I can't help you about this.
But to set a fixed image in the background of a UITableView you should :
- set background color of the UITableView to [ UIColor clearColor ] (and maybe the background of the cell too)
- set and uiimageview below the uitableview view that contains the image :)
In that way this should work.
But without xcode project I can't help you more ^^
Good luck
UITableViewController is a convenience class; you can equally just use UIViewController and implement the correct callbacks.
In OS 3.2+, you can just set UITableView.backgroundView. If IB doesn't let you do this, you can do it in code instead.
Alternatively, you might be able to wire up the view and tableView outlets differently, unless tableView just does (UITableView*)self.view.

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.