tabbed application with adwhirl using storyboard - iphone

I've tabbed application with storyboard. I want to have adwhirl below my tabbar. Though I'm customising my tabbar after clicking out at any item.I'm not able to change the position of tabbar at initial stage. And I also want my all tabbarviewcontrollers are of custom size, so that after inApp purchase the adwhirl will be removed and entire tabbarviewcontoller will resize again to its original position.Any idea how to achieve this.FYI I want to have adwhirl with iAd & adMob

get Apple's iAdSuite , and look at TabbedBanner and SplitViewBanner . you'll have to combine some effects from the two. the SplitViewBanner will show you how to embed another view-controller inside the BannerViewController, nesting viewControllers. i think the TabBarBanner code puts the ad "above" the tab-bar, but you can see how the tab-bar controller is created on the fly. if you combine the two concepts, you can probably get what you want.
additionally, while the examples are with these items on the fly, i was able to create a splitViewController in storyboard, and then re-set the rootViewController to be the bannerViewController containing the tabBarController.
might look something like this (again, assuming you've created the tabBarController in storyboard):
UITabBarController* tabBarController = (id)self.window.rootViewController;
CGRect tabBarViewFrame = TabBarController.view.frame;
tabBarViewFrame.origin.y -= application.statusBarFrame.size.height;
tabBarViewFrame.size.height += application.statusBarFrame.size.height;
tabBarController.view.frame = tabBarViewFrame;
// get BannerViewController from the SplitViewBanner of iAdSuite ;
// it should do the work of creating the space for your iAds only when necessary.
self.bannerViewController
= [[BannerViewController alloc] initWithContentViewController:tabBarController];
self.window.rootViewController = self.bannerViewController;

After so many researches I found that with Adwhirl this is not possible. This could be only possible if I want my AdMob & iAd at different places. And since I want my both ads at the same place with different time period . I can't achieve this in this way. So I did it in other way. In which I've taken an Extra UIView. Which will be added when I don't want ads. And will be removed when I need it. And instead of adding it below tabbar. I've integrated ads above tabbar. Thus I've fullfilled my requirement with some stitches.

Related

Dynamic number of pages in Watchkit Page Navigation

Is there any way dynamically create pages in a page-based navigation? In every example I read, the pages were created as Interface Controllers and linked in the Storyboard.
Here is the way to do it
WKInterfaceController.reloadRootControllersWithNames(["pageController", "pageController"], contexts: ["pageController", "pageController"])
To avoid infinite loop use:
static BOOL first = YES;
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
if (first) {
[WKInterfaceController reloadRootControllersWithNames:[NSArray arrayWithObjects:#"SinglePageICIdentifier",#"SinglePageICIdentifier", nil] contexts:[NSArray arrayWithObjects:#"First",#"Second", nil]];
first = NO;
}
}
I presumed you want to display several page of the same kind of data.
Apple Watch Programming Guide states the following:
This style is suited for apps with simple data models where the data on each page is not closely related to the data on any other page.
Therefore, I think you should stick to table views to display several items that are closely related (by kind) to each other. From my point of view, page-based controller navigation (swipe) is too slow / boring to be used for lots of pages. Also, I think it could take a lot of time to load the page-based controller.

Return to mainview from webView deployed using storyboard

I created a new project "Single View Application" and designed the mainView with Storyboard. My main view contains a UIButton that opens the camera, the camera scans barcode and automatically goes to a website. Now I created a webView programmatically so that website can open and also created a UIButton inside the webView. Now I want that UIButton to act as home botton and return to mainview. I am unable to do that, please help.
ViewController.m code: http://cl.ly/FKj8
My storyboard looks like:
You really should look into the View Controller Programming Guide -- by switching around the contents of a single view controller, you're making a lot of extra work for yourself with little benefit. By using multiple view controllers when you want to have different "screens" in your app, you can take advantage of storyboarding for easier development, and you automatically get better memory management (read: less potential for crashes), too.
However, to more directly answer your question... if you're putting the WebView into the view hierarchy with [self.view addSubview:webView], you can remove it with [webView removeFromSuperview]. (This means you'll have to keep a reference to the WebView around so you can refer to it when you want to dismiss it.)
I also noticed in the code you posted to cl.ly an unrelated method -deviceModel which uses uname() to get device information. This is a bad idea, for two reasons:
uname() isn't guaranteed to do something useful on an iOS device (even if it currently does). Use the UIDevice class instead if you need this kind of info, or...
Generally, you don't want to test for the device name to enable functionality in your app; instead, you should test for the capabilities you need. (For example, if you look for a device name starting with "iPhone 4" to test for a Retina display, you'll miss the 4th-generation iPod touch, and the iPhone-5-or-whatever-they-call-what's-next. Instead, use the UIScreen class.)

How to implement Ads in an iPhone Application so as to avoid reloading of ads in all the views?

Ok, i've this multi view IPhone application in which i've integrated adWhirl ads. That's the good news. The bad news is that i've literally implemented the adWhirl ads in each view controller, which means every time a view is pushed a new adWhirl object is created which takes time to load the AdMob/iAds advertisements. Now, I can't help thinking about this being the "wrong" way to go about the problem. So the question is, do I make a singleton ad object maybe in the appDelegate's didFinishLaunching method and use that ad object in all the view controllers or what I've done is pretty much how it should be done?
Put the ad in the appDelegate and reference or sub class it from all of the view controllers. I just finished a Tab Controller app that had a similar requirement. The performance gain was a nice bonus as well.
You could probably just add it to the window in the appDelegate.
[self.window addSubview:same_as_before.view];
[self.window addSubview:ad.view];
[self.window makeKeyAndVisible];
This way it will always be in the same spot on top of all other views and you won't have to deal with it again.

How to handle views?

How can I handle different views in XCode?
Let's say I want to show a different view when the user press a button.
UIViewController *viewSettings;
[viewSettings initWithNibName:(NSString *)#"SettingsViewController" bundle:(NSBundle *)nil];
This code don't work. The app crashes.
I have updated my XCode to the new version. How can I say my projects that they have to take the new SDK?
Thanks.
This is the correct line. Then you need to push it (pushViewController) onto a UINavigationController or add it to an existing view. Do a Google search for iPhone Beginner Tutorial First Application or something like that.
UIViewController *viewSettings = [SettingsViewController initWithNibName:#"SettingsViewController" bundle:nil];
1) You use a UIViewController to manage the view stack and ultimately which view is visible.
2) In your xCode project, modify the project or target "Base SDK" property. This will let you choose the minimum version of iOS to require of your users.
You need to read the Apple documentation for view controllers There are also some very good beginner books out there for iPhone programming

How to implement admob on view controller?

In my app, I want to implement admob and now only I have started to learn about it. So any one please guide me and is there any nice tutorial or sample?
It's extremely simple. Follow the guide here: http://developer.admob.com/wiki/IPhone#AdMob_iPhone_SDK
Once you have the SDK up, you simply do:
AdMobView *ad = [AdMobView requestAdWithDelegate:<your delegate>]; // start a new ad request
ad.frame = CGRectMake(0, 432, 320, 48); // set the frame, in this case at the bottom of the screen
[self.window addSubview:ad]; // attach the ad to the view hierarchy; self.window is responsible for retaining the ad
Download the Admob SDK for iPhone and look at the example projects. It's very simple.
If you choose to use the Interface Builder approach and follow their steps
there is one step missing: Add an AdViewController object to your UIViewController.h/m file and use that as the referencing object in IB. Otherwise you'll get the error:
"Must implement required method
-currentViewControllerForAd:(AdMobView *)adView in your delegate"
I realize this is a basic assumption, but it caught me for a minute and i've implemented AdMob 3 times in the past (using different methods, mind you).
Add an ad to a view using Interface Builder
Add AdViewController.h and AdViewController.m to your project (located in the IBSupport subdirectory).
Open Interface Builder.
Place a 320x48 UIView where you want the ad to appear.
Add an Object, and change its type to AdViewController.
Set the view outlet of the AdViewController to your UIView.
Set the currentViewController outlet of the AdViewController
to the UIViewController owning the xib.
Edit AdViewController.m to make sure that your publisher ID and
other options are set correctly.
Good thing to know, Mike. They also left out one step in Interface Builder. You need to select File's Owner, and drag from Ad View Controller to the new Ad View Object. I simply cannot comprehend why Admob would leave out these details, especially when many new programmers join they're community all the time. They really need help in the documentation & tutorials department.