How to put AdWhirl-banner fixed above TabBar? - iphone

My app consists of a TabBar and several TableViews. I want to have the AdWhirl-banner fixed just above the TabBar (only in the first TableView), but thus far I have not been succeeding.
Until now, I have implemented the following code into my TableViewController:
AdWhirlView *adWhirlView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[self.tableView addSubview:adWhirlView];
adWhirlView.center = CGPointMake(160, 342);
And it indeed shows the Ad i want to see, only it is partly covered by a section header (from the TableView), and when scrolling the Ad scrolls along.
How can I achieve that the Ad is both on top (in terms of top view) and at a fixed spot (above the TabBar)?
Any help is greatly appreciated!

You need to add it to the tabBar layer.
Try this:
[self.tabBarController.view addSubview:adWhirlView];
You may need to reposition it do it's not underneath the tabbar.
I also add a footer to the tables so they can be scrolled all the way up without the ad getting in the way.

You will likely need to create your own subclass of UIViewController, adding instances of both the AdWhirlView and UITableView to its view, either programatically, or in the nib file.
Anthoer, hackier way to do this would be to add the AdWhirlView as a header view in the existing table, but I'd opt for the first way. It will give you more control over how you want it to look and behave.

I'd think another alternative here would be to have a container UIView that contains both a UITTabBar which contains a UITableView. If you're on the right tab, you could just request an ad. If the request is successful, just shrink the tabbed view enough to make room for the ad at the top and insert it into the container UIView.

Related

Moving subviews from one view to another view without changing any position information in storyboard?

I have an iOS app in which i have created some view-controller in storyboard, the view-controller's view has some subviews. Now I want to add some scrollview in that view and want to move all those subviews in that scrollview.But the problem is when i drag those views to scrollview, interface builder is centering those subview, all the position information is lost.
I don't want to let interface builder to do that. Isn't there any proper way to solve this problem? I have already searched about this problem and found these two solutions but none is useful in my case.
Adding a subview to the current view without messing up positioning of objects in the view
I am unable to use this solution because, this is adding a view into another view while i want to add scrollview.
XCode - Is there a way to drag a component from one view to another without losing its frame?
Also this solution is not helpful for me because, storyboard file is messed up and corrupted when i did this.
Yes there is an easy way to do this:
Step 1: Select your views
Step 2: Go Editor > Embed In > Scroll View
Done!
PS. This is a very handy way to group views in fact. You can embed any views into a 'container' view, move it wherever you like (even cross-scene) retaining relative position information and then you could keep it as a group or unembed them.
If anyone comes across this question trying to find a way to do this programmatically (as I did), here's what I ended up using:
for (UIView *view in [_viewAdd subviews]) {
[_viewMain addSubview:view];
}
Note: addSubview removes the view from it's previous superview so there's no need to code for the removal

Newbie TableView challenges

I am building an app that requires a tableview control so that users can select multiple rows and act upon them in some way. I find it easy to load my data and display it using the UITableViewController but it seems when I do it this way I am unable to place any other controls on the page, such as a toolbar to give the user some actions to perform on the selected rows. I can place a toolbar control on the form in the storyboard, but it doesn't render in the emulator.
Using a UIViewController and placing a TableView on it seems to come with its own set of confusing challenges (that will make total sense once I conquer them).
Is there any advice for a smooth way of getting a table view with toolbar controls? Thanks!
don't use a TableViewController. Use a Standard ViewController, then add a UITableView to it, and adjust the size. This way you will be able to do whatever else you want on that view without limiting yourself to the tableView only functionality.
When you do this make sure you add the datasource and delegate to the connected table. Then add cellForRowAtIndex, number of sections, number of rows, and whatever other delegate methods you need for your table.
Good luck
Is there any advice for a smooth way of getting a table view with toolbar controls?
Yes there are few ways to accomplish this, one way would be adding a footerview to your tableviewcontroller check these
http://developer.apple.com/
UIButtons on tableFooterView not responding to events
Easier way to add this is using storyboard.
Just drag and drop a view in to your tableviewcontroller, then you can adjust the views size and put anything from objects menu to inside of the view.
Now the problem with that is view will not be stable position at the bottom of the page like a tabbar. Lets say you have only 1 row in your tableview, footer view will go up just below that 1 row, lets say you have hundreds of items in your tableview toolbar will be at the bottom of the rows.
The other solutions for your problem would be either create a custom view and adding it to current view or window (this is little bit adbance),but if you want this just google it.
Or just as you said, create a viewcontroller and put a uitableview inside. Dont forget to add <UITableViewDelegate,UITableViewDataSource> to your .h file and then you can call UItableview delegate methods.\
Good Luck.

iPhone: Adding a custom view to a UITableView Cell produces weird results

What I'm doing:
I have a custom ViewController called "MoreAppsViewController" - it displays/advertises several of the other apps I have created, and I use this same class/xib etc in several different apps. It controls a small view that gets displayed on options screens.
Normally I can just add this to any view with code such as:
MoreAppsViewController * moreApps = [[MoreAppsViewController alloc] initWithNibName:#"MoreAppsViewController" bundle:nil];
[self.view addSubview:moreApps.view];
-
The Problem:
I'm trying to display the same view in a UITableViewCell. This is the code:
moreApps = [[MoreAppsViewController alloc] initWithNibName:#"MoreAppsViewController" bundle:nil];
[cell.contentView addSubview:moreApps.view];
It does get displayed. However, some elements of moreApps.view appear lower than they should - they get drawn below the cell, but the rest of the elements get drawn in the cell correctly. Specifically, it's a scroll view that forms the main part of moreApps.view that gets pushed below where it should be (the scroll view and anything on it).
Any idea why this is happening or how to fix it? Any help would be much appreciated!
-
Lastly - The scroll view is just part of the .xib file, I don't do anything weird in the MoreAppsViewController either.
EDIT:
To clarify, by 'below' I mean further down the page. If I increase the cell's height, the scroll view is just pushed further down the page.
EDIT 2:
Here's what it was doing: (the bit below the cell should be appearing inside it)
Weirdly enough, placing the scroll view inside a dummy view fixes the problem (via the interface builder). Don't ask me why - feel free to explain though!
Seems to happen for any scroll view on a .xib, when placed inside a UITableViewCell of above default height.

Is it possible to put one UITableView over another UITableView in InterfaceBuilder?

I know I can use codes to add UITableView one by one.
[self.view addSubview:tableview1];//
[self.view addSubview:tableview2];//
I hope to do the same thing in InterfaceBuilder, when I drag one UITableView onto another one, the new one always pushes the old one to the bottom, rather than just stays over the old one of UITableView.
Welcome any comment
Thanks
If you have a parent view that will contain your tableviews then you shouldn't have any problem. If you're trying to place them directly in a window then I could see a problem. If things aren't lining up the way you want you can always change their position via the Size Inspector or by nudging them with the arrow keys (shift-arrow key moves in 10 pixel increments).
Why anyone would want a tableview on top of another tableview escapes me.
Your parent view should be a subclass of uiviewcontroller and your xib should have the root view as a uiview and not uitableview.
I used two overlapping table views to show two different contents on the same view, which could be toggles using a segment switch. Apparently my client requirements were vague enough that I couldn't just filter out data like how the phone app displays all calls/missed calls list.

iPhone UIImage overlapping text

I have a view with a UIScrollView, UIImageView for a background, and a UITextView. I have created several other views just like this and they all come out okay - with a background image and scrollable text but for some reason, now I can't make that work. Either my image overlaps all of the text so that I can't read it or the UITextView default background (white) shows up so that the user can't see the background image. What could be causing this problem?
Do you use Interface Builder or build the views hierarchy in code?
In both cases you should make sure that the order of your views is correct.
In IB the view that you want to appear on top of all the rest has to be under the rest of the views.
In code, make sure that the text view is the last to be added to the hierarchy.
You could also use the next code in order to check if this is the problem:
[self.view bringSubviewToFront:textView];
Okay, it must have had something to do with choosing the delegate. I can't say that I completely understand how I fixed it but it had to do with declaring the delegate in IB.