Archive for 六月, 2010
如何配置iAd
by Elton on 六.29, 2010, under iPhone
1. 导入iAd.framework
2.选择要定制iAd的TabViewController.h , 添加代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #import <UIKit/UIKit.h> #import <iAd/ADBannerView.h> @interface TabViewController : UIViewController<ADBannerViewDelegate> { ADBannerView *adView; UILabel *adStatus; } - (void)bannerViewDidLoadAd:(ADBannerView *)banner; - (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave; - (void)bannerViewActionDidFinish:(ADBannerView *)banner; - (void)bannerView:(ADBannerView *) didFailToReceiveAdWithError:(NSError *)error; - (void)adAvailabilityDidChange; @property (nonatomic, retain) ADBannerView *adView; @property (nonatomic, retain) UILabel *adStatus; @end |
3.对应的TabViewController.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #import "TabViewController.h" @implementation TabViewController @synthesize adStatus; @synthesize adView; // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 250, 320, 50)]; self.adView.delegate = self; self.adView.backgroundColor = [UIColor whiteColor]; [self.view addSubview:adView]; adStatus = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 200, 30)]; [self.view addSubview:adStatus]; NSLog(@"Trying to change the ad status"); } - (void)adAvailabilityDidChange { NSLog(@"[iAd]: Ads are available! Let's display one!"); // if([ADManager sharedAdManager].canPresentModalAd == YES) // [[ADManager sharedAdManager] presentModalAdFromViewController:self]; } - (void)cancelBannerViewAction { NSLog(@"Banner was cancelled!"); self.adStatus.text = @"[iAd]: Bannes was closed."; } - (void)bannerViewDidLoadAd:(ADBannerView *)banner { NSLog(@"[iAd]: Ad did load."); self.adStatus.text = @"[iAd]: Ad did load."; } - (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave { NSLog(@"[iAd]: An action was started from the banner. Application will quit: %d", willLeave); self.adStatus.text = @"[iAd]: An action was started from the banner. Application will quit: %d", willLeave; return YES; } - (void)bannerViewActionDidFinish:(ADBannerView *)banner { NSLog(@"[iAd]: Action finished."); self.adStatus.text = @"[iAd]: Action finished."; } - (void)bannerView:(ADBannerView *) didFailToReceiveAdWithError:(NSError *)error { NSLog(@"[iAd]: Faild to load the banner: %@", error); self.adStatus.text = @"[iAd]: Faild to load the banner: %@", error; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } @end |
理解iPhone项目的BaseSDK和DeploymentTarget含义
by Elton on 六.17, 2010, under iPhone
iPhone OS的版本众多,很多用户由于各种各样的原因没有升级到最新版,这就给我们开发者带了麻烦。作为开发者,我们都希望软件的受众越多越好。怎么样让软件尽量适应最多的iPhone OS?这里我们就应该了解iPhone项目的Base SDK和iPhone OS Deployment Target。
Base SDK指的是当前编译用的SDK版本。iPhone OS Deployment Target指的是编译出的程序将在哪个系统版本上运行。
用更简单实用的语句描述如下:
Base SDK设置为当前xcode所支持的最高的sdk版本,比如”iphone Device 4.0″。iPhone OS Deployment Target设置为你所支持的最低的iPhone OS版本,比如”iPhone OS 3.0″。
这样设置之后,你的程序就可以运行于从iPhone OS 3.0 到 4.0的设备之上。当然,前提是,你没有用到4.0新加的API。
那么如果需要使用到新的API怎么办呢?请参考官方Sample MailComposer http://developer.apple.com/iphone/library/samplecode/MailComposer/index.html
转载自http://www.cnblogs.com/vinceoniphone/archive/2010/06/13/1757743.html


