How to add iAd to Ipad - iphone

I am working on an universal app and want to add an Ad Banner to it, the iAd is working fine in iPhone, But how to control that for iPad.
Because latest version of iPad supports iAd but in different size format and that gives error in my interface Builder when i targets for iPad 3.2.

Well, I haven't done that yet in my iPad apps, but here's how I would do it.
First of all, I would mark the iAd framework as a weak/optional link. This would be the first step for compatibility with pre-iOS4. If you don't do that, the app may not even startup
Secondly, I wouldn't add it in the nib file (if using one). I would rather add it programmatically to be ale to check if the iAd framework is available on device.
Finally check if iAd is present. If it is, setup the ad, but if it isn't, just continue, or setup admob instead or something.
How to check that iAd is present? One of the simple ways is doing something like this
if(NSClassFromString(#"ADBannerView") != nil) {
//iAd is present
}
Hope this helps

Related

convert an ipad app to iphone app with custom views

This might be a repeat question.But i have a problem. I have an iPad app functional. The app is built in iOS 6. When i started building it i chose iPad as targeted device NOT universal. Now my client has asked for an iPhone version of it.In my iPad app i keep adding custom views as the client clicks "Add More".I add a custom view which is bunch of textfields, buttons etc.So i copied my iPad app and changed the Targeted device family to iPhone once and also Universal next time and tested it. So when i launch the app in iPhone configuration (keeping the targeted device family as Universal) my view controller stays like that on iPad. I cannot scroll the app also(not up/down..nor sideways). Is this the correct way to convert iPad app to iPhone app . Also everything is still with scale to iPad. Should i start a new project and start everything from scratch.Set the storyboard to fit according to iPhone configuration? In my research people said just change the targeted device family to Universal. But it doesn't work. Please let me know if you need more information. Thanks.
It is possible to convert the current project you have to an app that can be used universally, but it would take more time than simply just creating a new project that allows universal usage, and adding in the files of which you used for your iPad project.
Hint: You can use more than one storyboard when the project was created universally. It will automatically set this up for you.
I would also advise that you separate your files into what works universally, and what is specific for the iPhone or the iPad.
Happy Coding!
After many search i found that it possible to have an application for both Iphone and ipad devices.but in your code you should define unique ui for each device(two xib file).

Change app to only iPhone deployment

Im using Xcode 4.1 lion release. My app was rejected because it only works on the iPhone, this is how it should be, but i guess i didnt set my app up so it only works on the iPhone. How would i do so?
I go to Targeted Device Family under my project build settings and i have iPhone selected.
`
What else do i need to do. Thanks
EDIT: During the app review it was still set up under device family as iPhone
Remove and iPad xib files that were created initially. By default Xcode makes an iPad folder when you select the universal build, remove that and you should be good. Other considerations might be to remove iPad launch images if they are present, or any iPad specific code like popover view controllers etc.

Is it possible to target both iphone & ipad using the same project?

The subject is self explanatory, I have a current iPhone project using Monotouch/MonoDevelop and I want to be able to target iPad too.
Is there any way that the application could do a "stretch"? I have not tested the app in an ipad, only in the emulator and it does not look good.
Thank,
Ignacio
Yes, you can. You can either programmatically check if app is running on ipad or on iphone and set different nib files for each mode.
Also you may use the same views either created programmatically or through Interface Builder, but in that case you should set your resizing masks properly.

add iPhone functionality to iPad app

I have been developing an iPad app. I now want to make it work on the iPhone also. What do I do in Xcode so it can work both ways?
(I am not concerned about adapting to the smaller screen -- that part I can figure out. But how do I get it to start up on the iPhone?)
In the project's build properties, change the target from "iPad" to "iPhone/iPad". Make sure you continue to target iOS 3.2, however, so that you don't break iPad support, and test on both platforms.

Simulator flips to iPhone

I created my first universal app by using the universal app template.
I set up xib files and main view controllers for both iPhone and iPad and the iPhone version runs fine.
Yet even though I change the simulator hardware to iPad/3.2 when I test, the simulator changes back to the iPhone.
Please help.
Dan
I found that if I change the targeted device in the project settings from iPhone/iPad to iPad, I can test. I'll have to change it back when I'm ready to release the product. Who knows if it will work.
Side issue: I found that the new imageWithCGImage:scale:orientation is not supported in 3.2. I have to branch upon the interface idiom.