views:

139

answers:

2

I'm trying to resize my app's view whenever an iAd is scrolled down from the top. The problem is that in run-time, when i set the resized frame size of the relevant view, the resizing doesnt happen 9so the iAd is draw on top of the top 50 vertical pixels).

If I set the UIView size at design-time, then I see that the view is resized (when i run the app).

So what am i doing wrong at run-time that is causing my resizing to not occur?

The structure of my controller's NIB looks like this:

> > View

>   > View (associated with IB 'contentView')

>     > CustomView (UIView)

>        - ScrollView

>        - Toolbar (top)

>        - Toolbar (bottom)

In code the adBannerView is added like this: [self.view addSubView:adBannerView];

conteView's origin.y and size.height is what im updating (to make it y = 50, and height = original height - 50). This should scale it down so that enough room is made to dispaly the banner on top (50 pixels in height).

A: 

Are you sure the view is not nil? Did you hook it up in Interface Builder? If you're calling -setFrame on the view and nothing is happening, it's likely the view is not valid.

Matt Long
One of the things i did is set the origin.y and size.height of the view's frame at design-time thru interface builder. Interestingly, when i do this the interface builder doesnt look the way i expect it to, BUT when i run the simulator it does.In a nutshell, the problem is w/ updating the origin and the size of any UIView at run-time so that it makes room for the iAd (so iAd isnt overlapping the other views). The iAd banner (which itself is a UIViw I think) shows up were i expect (top).Fyi, i'm using this as a ref:www.raywenderlich.com/1371/how-to-integrate-iad-into-your-iphone-app
AlvinfromDiaspar
However, I can never be too sure. I certainly hope my problem is with the view not being hooked up properly. What do i need to ensure my view(s) are valid?
AlvinfromDiaspar
Did you drag a connection from your view controller's file's owner in Interface Builder to the view in question? Also, you can set a break point in the debugger and make sure the view is not 0x0 (nil) when you view controller loads.
Matt Long
I did drag it (as mentioned in the IB diagram i drew out in the original post).I have a feeling that it is NOT nil, but rather that it is due to rather complex layout that i have (possible?).Basically I have a View within a View (the inner view is assocaited with a UIView that exists in code which is used strictly to display a wallpaper image). The reason why i did it this way is so that i can use a ScrolLViewer on top of the wallpaper (so wallpaper doesnt scroll). To make things crazier, in code, I add another view (canvas) that is my drawing area. It gets added to the scrollviewer.
AlvinfromDiaspar
@Matt. Fyi, regarding your last comment, I dragged from File Owner to the View in question all thru the Object Owner window (not the GUI designer window). Maybe I should try making the File Owner connection with the actual GUI view in the designer window?
AlvinfromDiaspar
When you say GUI designer window, do you mean Interface Builder? It is in Interface Builder where you must make your connections. And when you create more complex views in Interface Builder, you have to be careful you are connecting your outlets to what you think you are connecting them to or it won't work.
Matt Long
Some of my Views i have a connection to. Some views i dont have a outlet assoc. with it. Yes, im speaking of the IB.Im losing tremendous productivity right now because what i see in IB is NOT what I see in the simulator. Could this possibly be due to simply the nature of using IB, or could this mean a guaranteed 'bug' in code?
AlvinfromDiaspar
btw, sorry, i didnt realize i had to click to "See more comments".
AlvinfromDiaspar
A: 

I resolved my issue, though in a work-around way. I think the problem was that my view layout tree was quite complicated. Ex, i had a scrollviewer within a custom UIView. The scrollviewer was adding a UIView as its content at run-time. And on top of all this I was trying to resize various views.

But for some reason, the view(s) never managed to be bottom-justified (its always top-justified).

AlvinfromDiaspar