Admob Integration in iPhone [closed] - iphone

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Could any one helpme with how to add admob codes in Appdelegate file.
Currently i have the following code in my appdelegate file.
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
[web_online loadHTMLString:#"<h1>Loading...</h1>" baseURL:nil];
current_word = [[NSString alloc] initWithString:#"keyword"];
current_url = [[NSString alloc] initWithString:#"http://www.google.com"];
#if 0
if ([[NSUserDefaults standardUserDefaults] boolForKey:#"auto_correction"] == NO)
search_main.autocorrectionType = UITextAutocorrectionTypeYes;
else
search_main.autocorrectionType = UITextAutocorrectionTypeNo;
#endif
//search_main.keyboardAppearance = UIKeyboardAppearanceAlert;
search_main.autocorrectionType = UITextAutocorrectionTypeNo;
search_main.autocapitalizationType = UITextAutocapitalizationTypeNone;
[self init_data];
[self init_sound];
[window addSubview:nav_main.view];
[window addSubview:view_start];
#ifdef DISABLE_ADMOB
view_ad.hidden = YES;
#endif
// Override point for customization after application launch
[window makeKeyAndVisible];
}
My question is how to add the admob codes ie the code below
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = #"67576511260";
// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
in the appdelegate file.
Everything else i have done.
All my code is done in appdelegate file . ie why this??

There's two questions to answer here.
Firstly, just put the code before the [window makeKeyAndVisible] replacing instances of [self view] with window and it should work.
Secondly, why is all that in your app delegate? The standard way of writing iPhone apps is to use a UIViewController with UIView objects (apple's variant on MVC) - this separates out your data and presentation code nicely.
More importantly here, all libraries like this will assume that you've used this pattern - hence you are finding trouble getting the admob code to work - it's designed to fit inside a UIViewController, not inside an app delegate.
Why have you decided not to use view controllers?

Related

how to get selected image from PhotoAlbum and how can i save it in Application document directory? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
in my iOS application, how to get selected image from PhotoAlbum and how can i save it in Application document directory.
You can do it with the help of UIImagePickerController
-(void)showImagePicker
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
}
Now Handle user's selected image with following delegate method
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];//Do whatever you want to do with your image.
}
For more clerity how things work please go through this tutorial
Hope this helps.

iPhone:Tutorial of json in ios 5 [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am first time implementing json in my app.
and in my app I have to pass parameters from my app to webservice and according to that i can get response from web service but I am not able to find any tutorial in which I can pass parameters from my app in ios5
so is there any tutorial on net from which I can get tutorial which is useful to me.
I tried to find using google but i did not succeed.
Following steps follow for the integrate the json in to our project.
1) Copy paste the below file into your project.
2) Create new Group name as help which contain the following files.
3) Create the new file into Support Files which is name as a constant.h
#define WEB_SERVICE_URL #"Your server url" //#"http://demo.google.com/webservice/"
#define USERNAME #"Your user id"//static username to send everytime
#define PASSWORD #"Your Password"//static password to send everytime
4) Change the above the variable link where is your web service exist that means url of your webservice ”WEB_SERVICE_URL”
5) Open “Rest.h” file and create the one method.
-(void)Get_StoreDetails:(SEL)seletor andHandler:(NSObject*)handler andCountryId:(NSString *)CountryCode;
6) Open “Rest.m” file and which argument to pass to server that method to code.
-(void)Get_StoreDetails:(SEL)seletor andHandler:(NSObject *)handler andCountryId:(NSString *)country_id{
NSDictionary *req = [NSDictionary dictionaryWithObjectsAndKeys:#"content/get_stores",#"request",
[NSDictionary dictionaryWithObjectsAndKeys:USERNAME,#"username",
PASSWORD,#"password",
country_id,#"country_id",
nil],#"para",nil];
[[[JSONParser alloc] initWithRequest:req sel:seletor andHandler:handler] autorelease];
}
7) now the Rest application is ready for the send the request and then now this method call in to our view controller.
Following code put into the “viewWillAppear” method in .h file
#import <UIKit/UIKit.h>
#interface JsonDemoAppViewController : UIViewController{
UIAlertView *alertCtr;
}
#property(nonatomic,retain)NSMutableArray *arrForStores;
- (void)getData:(id)object;
#end
Following code put into the “viewWillAppear” method in .m file and import “Rest.h”.
- (void)viewWillAppear:(BOOL)animated {
self.arrForStores=nil;
//============================Json Initialization===================================================
REST *rest = [[REST alloc] init];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[rest Get_StoreDetails:#selector(getData:) andHandler:self andCountryId:#"12"];
alertCtr = [[[UIAlertView alloc] initWithTitle:#"\nPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
[alertCtr show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
// Adjust the indicator so it is up a few pixels from the bottom of the alert
indicator.center = CGPointMake(alertCtr.bounds.size.width / 2, alertCtr.bounds.size.height - 50);
[indicator startAnimating];
[alertCtr addSubview:indicator];
[indicator release];
//===================================================================================================
}
Then the reply comes into server that time object store into the variable that time we create the metod which calls.
- (void)getData:(id)object{
NSLog(#"%#",object);
if ([object isKindOfClass:[NSDictionary class]]) {
NSLog(#"Controll comes here..");
//IF your response type is NSDictionary then this code to run
}
if ([object isKindOfClass:[NSArray class]])
{
self.arrForStores=[NSArray arrayWithArray:(NSArray*)object];
//IF your response type is NSArray then this code to run
}
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
[alertCtr dismissWithClickedButtonIndex:0 animated:YES];
}
Download the source code From Here

ViewController doesn't show until I quit and relaunch app

I have just made my app universal by combining separate iPhone and iPad projects. Everything seems to be working but there is one major bug.
When the iPad app launches it just displays a black screen (presumably the window) and status bar. When I press the home button I suddenly see the SplitViewController as it disappears. When I open the app up again the SplitViewController is displayed.
I can't figure out why the controller only displays after I close and reopen the app. Any ideas?
(I don't have any idea what is causing this so if you need code samples from specific places let me know).
Thanks.
Edit:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Appirater appLaunched:YES];
// Registers this class as the delegate of the audio session.
[[AVAudioSession sharedInstance] setDelegate: self];
// Allow the app sound to continue to play when the screen is locked.
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
justOpened = YES;
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
{deleted}
} else {
[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
CGRect rect = CGRectMake(-2, self.window.frame.size.height-29, self.window.frame.size.width+2, 29);
imgBar = [[UIImageView alloc] initWithFrame:rect];
imgBar.contentMode = UIViewContentModeScaleToFill;
imgBar.image = [UIImage imageNamed:#"wood_btm.png"];
imgBar.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin;
self.splitViewController.showsMasterInPortrait = YES;
self.splitViewController.title = #"Exams";
self.splitViewController.splitPosition=280;
}
return YES;
}
Update:
By messing around with the window's background color I discovered that for some reason it was at the top of the view hierarchy. I then made the window's background color clear and I could see the SplitViewController. Strangely I can also interact with it. So essentially I have solved the problem by making the window clear. This is obviously not the ideal solution though so if anyone can think of a cause let me know.
[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
return YES;
should be at the end of -applicationDidFinishLaunching:WithOptions: method.
By messing around with the window's background color I discovered that for some reason it was at the top of the view hierarchy. I then made the window's background color clear and I could see the SplitViewController. Strangely I can also interact with it. So essentially I have solved the problem by making the window clear.

How to repeat a UILocalNotification Sound [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
How can I repeat a UILocalNotification sound?
-(IBAction) scheduleNotification1 {
local1 = [[UILocalNotification alloc] init];
// create date/time information
local1.fireDate = [NSDate dateWithTimeIntervalSinceNow:2];
local1.timeZone = [NSTimeZone defaultTimeZone];
// set notification details
local1.alertBody = #"2!";
local1.alertAction = #"View";
//local1.soundName = UILocalNotificationDefaultSoundName;
//local1.soundName = #"alarmsound.caf";
local1.soundName = #"29.mp3";
// set the badge on the app icon
local1.applicationIconBadgeNumber = 1;
// local1.repeatInterval =NSSecondCalendarUnit;//// NSMinuteCalendarUnit;
//local1.repeatInterval =1 ;
// Gather any custom data you need to save with the notification
NSDictionary *customInfo = [NSDictionary dictionaryWithObject:#"ABCD2" forKey:#"yourKey1"];
local1.userInfo = customInfo;
// Schedule it!
[[UIApplication sharedApplication] scheduleLocalNotification:local1];
//[local1 release];
}
Please provide some sample code.
Sorry a7mad, I am afraid to say that but it is not Possible to Repeat the sound of UILocal Notification.I hope you have checked Other Questions Of SO. All of them have Negative result.
I can give you a suggestion to Call an Alert View Or ActionSheet on Click of "View" Button of LocalNotification and Continue your actions on that Controller as they can be controlled...

Label adds up to players score at GameOver Scene: Objective-C [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
So I've seen it everywhere in apps/games and other things its when you score or you get game over and the score number adds up to your score from zero. I want it so in about 1 second a label goes from the text: 0 to and integer that is stored with the players score.
Create a UILabel to display the score, and use an NSTimer to update the UILabel's text property. Apple doesn't ship a class that will do it all for you.
You need two variables; the currentScore and the current score being displayed. You will also need a timer to handle updating the ui.
When your score changes, update currentScore to the final score you want. Then start a timer that increments the displayedScore until it gets there i.e.
-(void)scoreUpdater:(NSTimer *)timer {
// Update the score
displayScore ++;
[scoreLabel setText:[NSString stringWithFormat:#"%i", displayScore]];
// Have we got there yet?
if (displayScore == currentScore) {
[scoreTimer invalidate];
[scoreTimer release];
scoreTimer = nil;
}
}
I would go by using an NSOperation that sleeps and add the points (actually it may work even without sleeping). Something like:
NSInvocationOperation *op = [[NSInvocationOperation alloc] initWithTarget:self
selector:#selector(updateScore)
object:nil];
[queue addOperation:[op autorelease]];
-(void)updateScore {
while (tot < 1.0) {
displayingScore += score*incr;
tot += incr;
// update score label to displayingScore
[NSThread sleepForTimeInterval:0.05];
}
}