Examples:
http://itunes.com/XuanChen (for computer and iphone)
itms://itunes.com/XuanChen (for iphone only, only one redirection)
http://itunes.com/apps/XuanChen/MassageMap3D
itms://itunes.com/apps/XuanChen/MassageMap3D
More info:
http://developer.apple.com/library/ios/#qa/qa2008/qa1633.html
Showing posts with label iPhone programming. Show all posts
Showing posts with label iPhone programming. Show all posts
Friday, December 10, 2010
Tuesday, December 7, 2010
How to Hide Status Bar or Change Its Style in iPhone App
By default, the status bar is displayed in iPhone App. If your root view frame origin is (0,0), it will be displayed just below the status bar.
If you want to hide the status bar, add one entry to the property list of your app:
Status bar is initially hidden
and make sure it is checked.
If you want to change the style of the status bar, add one entry to the property list:
Status bar style
Do not try to change status bar style or hide it in Interface Builder. That is only for visualizing other views or controls, not really changing the status bar.
If you want to hide the status bar, add one entry to the property list of your app:
Status bar is initially hidden
and make sure it is checked.
If you want to change the style of the status bar, add one entry to the property list:
Status bar style
Do not try to change status bar style or hide it in Interface Builder. That is only for visualizing other views or controls, not really changing the status bar.
Saturday, December 4, 2010
Error: unrecognized selector sent to instance
The error means an object does not respond to a selector sent to it. Various reasons can cause this error. Today I found another one: assigning to instance variable in class method can corrupt an object and cause it not to respond to a selector which it should.
For example, you have a view controller vc. By all means you expect [vc.view addSubview:anotherView] should work but you got error:
(null): unrecognized selector sent to instance 0xblah
Then you found that this view controller has a class method which updates some instance variables. Since it worked before, you think it is OK to do that. However, after some other coding, the application was suddenly broken, and you got that error. You can still NSLog(@"%@",vc.view) and it seems to be fine, but when you check [vc.view respondsToSelector:@selector(addSubview:)] you get NO.
This is totally insane. Then you noticed the compiler output:
warning: instance variable 'adView' accessed in class method
Then you remember you did something dubious: modifying instance variable in class method. In C++ such code won't compile but in objective-c it is just a warning.
After fixing this, the error disappeared.
The lessons learned:
1. Do not access instance variables in class method. Even if it works today, it may break tomorrow.
2. Pay attention to warnings. They said bad C++ code is like bullets which can shoot your toe. I would say objective-c is even worse.
For example, you have a view controller vc. By all means you expect [vc.view addSubview:anotherView] should work but you got error:
(null): unrecognized selector sent to instance 0xblah
Then you found that this view controller has a class method which updates some instance variables. Since it worked before, you think it is OK to do that. However, after some other coding, the application was suddenly broken, and you got that error. You can still NSLog(@"%@",vc.view) and it seems to be fine, but when you check [vc.view respondsToSelector:@selector(addSubview:)] you get NO.
This is totally insane. Then you noticed the compiler output:
warning: instance variable 'adView' accessed in class method
Then you remember you did something dubious: modifying instance variable in class method. In C++ such code won't compile but in objective-c it is just a warning.
After fixing this, the error disappeared.
The lessons learned:
1. Do not access instance variables in class method. Even if it works today, it may break tomorrow.
2. Pay attention to warnings. They said bad C++ code is like bullets which can shoot your toe. I would say objective-c is even worse.
Monday, November 29, 2010
UIViewController viewWillAppear not called
If you add the view of a UITabBarController as subview to another view controller. When you tap the tab bar to swap in a new view, viewWillAppear of that view's controller will not be called. This causes problem because many times you use viewWillAppear to refresh a view managed by UITabBarController.
One workaround is to subclass UIView for the view you want to update, and move the stuff from viewWillAppear to drawRect.
One workaround is to subclass UIView for the view you want to update, and move the stuff from viewWillAppear to drawRect.
Saturday, November 27, 2010
The Simplest Way to Add iAd Banner to Your iPhone Application
It is a bad idea to modify each view controller to add iAd banner. The simplest way to do that is to create a new root view controller and add an AdBannerView and your old root view to it. Do it in your application delegate:
[rootVC.view addSubview:oldRootVC.view];
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
adView.frame=CGRectMake(0, 0, 320, 50);
AdVC* rootVC = [[AdVC alloc] initWithNibName:@"AdVC" bundle:nil];
[window addSubview:rootVC.view];
[rootVC.view addSubview:oldRootVC.view];
[rootVC.view addSubview:adView];
rootVC.view.frame = window.screen.applicationFrame;
oldRootVC.view.frame=CGRectMake(0, 50, 320, 480-50-20);
This will add a banner to all of your views, and it also allows you to easily remove the banner if the user choose to upgrade.
This will add a banner to all of your views, and it also allows you to easily remove the banner if the user choose to upgrade.
How to fix status bar covering UIView
Sometime it is annoying that the status bar covers your UIView, and there are various other problems about the view location.
A simple fix is
rootVC.view.frame = window.screen.applicationFrame;
A simple fix is
rootVC.view.frame = window.screen.applicationFrame;
Subscribe to:
Posts (Atom)