With iPhone OS 4.0 and above we can send SMS right from within our application. Now our application can invoke the SMS composer screen just like we invoke the Mail composer screen. We need to invoke an instance of MFMessageComposeViewController and assign the delegate, recipients and body of the SMS. The code snippet is provided below:
Read the rest of this entry »
The FBConnects’s FBDialog class has a problem with the cancel button. When user taps the cancel button, the delegate method “dismissWithSuccess” is called instead of “dialogDidCancel“. This flaw in the FBConnect SDK makes it difficult to determine whether the user has tapped on cancel button or not. We can overcome this issue by editing FBDialog.m in the FBConnect. Add the below code as the first line in FBDialog.m’s webViewDidFinishLoad : methods
dismissWithSuccess
dialogDidCancel
webViewDidFinishLoad :
[_webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('cancel').onclick = function onclick(event) { window.location.href = 'fbconnect:cancel'; }"];
This should fix the issue and dialogDidCancel should get called correctly..!
For adding internationalization support to iPhone Settings.bundle, follow these steps:- 1. Close the Xcode IDE 2. Drag and duplicate the settings bundle onto the desktop (or wherever) 3. Open bundle contents by selecting “Show Package Contents” from the right click menu options 4. Drag Root.strings into the en.lproj folder 5. Duplicate the en.lproj folder and rename to whatever language you want (using 2-letter code. Eg: fr.lproj for French) 6. Replace the original settings bundle with the new one. 7. Open Xcode IDE and the new files and folders should be there This methods works fine in the simulator and on my iPhone device.
iPhone OS 4 is the next generation of the world’s most innovative mobile operating system. Its unique capabilities and new technologies will change what you thought was possible on a mobile platform. With a rich set of over 1500 new APIs, iPhone SDK for iPhone OS 4 provides you with an amazing range of technologies to enhance the functionality of your iPhone and iPod touch apps. iPhone Developer Program members can visit the iPhone Dev Center to download the iPhone SDK 4 beta now.
iPhone OS 4 delivers seven new multitasking services that allow your apps to perform tasks in the background while preserving battery life and performance. These multitasking services include:
Some times we would like to move the info.plist to other directories than the default project root directory. In such cases XCode would throw warning like “Warning: The Copy Bundle Resources build phase contains this target’s Info.plist file ‘Resources/Info.plist’.”
The Info.plist file belongs directly inside of the bundles Contents folder — that is to say, one level up from the Resources subdirectory. Thus copying Info.plist to that would serve little purpose, and might even be evidence of programmer oversight on something (as Xcode might think), hence the warning. The Info.plist should not actually be a member of any target. The check boxes in the Get Info window of the info.plist should be unchecked and this warning can be avoided.
Hope this helps..!
Today while I was working with some CoreGraphics API’s, I encountered a error which I was seeing it for the first time. CG for dumping an error “CGGStackRestore: gstack underflow” in the console everytime I invoked a method that was doing some CG based operations. Googling around I found that in CoreGraphics, you can save (CGContextSaveGState) and restore (CGContextRestoreGState) the graphics state. When the state is saved, a copy is put on the graphics state’s “stack”, and when it is restored, the top state on the stack is removed and used. If we restore the state more times than we save it and then when we try to remove and use the top item of the stack, the stack is empty, causing a stack “underflow” error. So just make sure you have enough save-restore state methods called and it will fix the issue.
CGGStackRestore
With Flash Professional CS5, we can now build applications for iPhone and iPod touch using ActionScript 3. These applications can be delivered to iPhone and iPod touch users through the Apple App Store. A public beta of Flash Professional CS5 with prerelease support for building applications for iPhone is planned for later this year. At MAX 2009, Adobe showed a number of applications and games for iPhone that have been built using a prerelease version of Flash Professional CS5. The tooling update allows developers to use Flash technologies to develop content for iPhone and iPod touch. Developers can write new code or reuse existing web content to build applications for iPhone. Because the source code and assets are reusable across the Flash Platform runtimes,—Adobe AIR and Flash Player—it also gives developers a way to more easily target other mobile and desktop environments.
Safari supports audio and video viewing in a webpage on the desktop and iPhone OS. You can use audio and video HTML elements or use the embed element to use the native application for video playback. In either case, you need to ensure that the video you create is optimized for the platform and different bandwidths.
audio
video
embed
iPhone OS streams movies and audio using HTTP over EDGE, 3G, and Wi-Fi networks. iPhone OS uses a native application to play back video even when video is embedded in your webpages. Video automatically expands to the size of the screen and rotates when the user changes orientation. The controls automatically hide when they are not in use and appear when the user taps the screen. This is the experience the user expects when viewing all video on iPhone OS.
One of my colleague found this nice article on the web which explains things we need to do and not to do to customize a UITableView and make it look great than a plain dump table.
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
I got this error while building an iPhone application that is going to use APNS. I am still trying to figure out what is causing this problem. A more detailed error message is here:-
"Error Domain=NSCocoaErrorDomain Code=3000 UserInfo=0x113e80 "no valid 'aps-environment' entitlement string found for application" APNS Error
APNS Error
XCode: Could Not Support Development
Today when I started my work on an iPhone project, my XCode failed to mount my iPhone. The XCode organizer was showing an orange dot next to it instead of the usual green one. Organizer complained “Could Not Support Development”. I tried restarting my XCode, launched iTunes but in vain. iTunes was able to mount my iPhone but XCode simply failed and I was not able to test my app’s on my phone. Read the rest of this entry »
Error Starting Executable
Quite a few times in our iPhone application development cycle we would encounter XCode error “Error Starting Executable – No provisioned iPhone OS device is connected.” even when we know the device is connected to the machine. This error occurs when the connected device is not configured in the XCode->Organizer. Organizer would fail to mount the device as the version of XCode installed on the developer machine may not support the version of iPhone OS installed on the device.
If you ever need to add a image as background for an UIView then do it like this (Make sure the image is in your app’s resource bundle):-
- (void)viewDidLoad { self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"MyBackground.png"]]; }
This is my first post using iPhone 3.0 Wordpress application. This is awesome cool in that now I can blog when I am travelling. I will write more about this app as I begin to use more of it.
the first feedback would be I am missing all the formatting options that I take for granted on desktop version of wordpress.
Many iPhone projects would require setting some numeric value on tabBarItem called badge. We can set the badge value for a tabBarItem by:-
Fig: UITabBarItem With Badges
Too Many Digits In Badge
Apple’s has announced a push notification service for the iPhone that it’ll provide to all developers. It’ll maintain a persistent IP connection to the phone and let a 3rd party server ping Apple’s notification service in order to push out notifications to users device, which can be in the form of badges, sounds or custom textual alerts. According to Apple, the service will preserve battery life and maintain performance, not to mention work over WiFi or cellular.
We can use the UITextField’s delegate method
- (BOOL)textField: (UITextField *)textField shouldChangeCharactersInRange: (NSRange)range replacementString: (NSString *)string
to set the maximum character length.
This can be done by doing the following:
#define MAX_LENGTH 10 - (BOOL)textField: (UITextField *)textField shouldChangeCharactersInRange: (NSRange)range replacementString: (NSString *)string { if (textField.text.length >= MAX_LENGTH && range.length == 0) { return NO; } else { return YES; } }
There might be need at several stages of iPhone application development to insert a new view on top of other views. This can be achieved by setting the zPosition value of the view in question. If a View has a zPosition that is bigger than another views zPosition it will appear on top of the other view.
Messed Up Icons With iPhone OS 3.0 Beta 5
With the latest release of iPhone OS 3.0 seed 5, the icons of the applications are being messed up. This mostly occurs when we install updates to the applications from App store. Few applications will not have any icons altogether, few apps have icons of their neighbouring apps like shown in the figure. iPhone OS 3.0 beta 5 is lot more buggier than beta 4 or beta 3. Also I have observed beta 5 drains the battery very fast. My iPhone lost more than half of its power over night even without performing any tasks while lying idle. Seems Apple has purposefully made beta 5 buggy so that users are forced to move to the final version expected in the WWDC.
On the screenshot we can observe that, PingPongLite application doesnt have icon at all and NewsPro and Bloomberg have same icons.
However on a positive note, if we restart the iPhone, all icons are restored to their original application icons.
The other day I was trying to build GData with one of my iPhone applications built on iPhone SDK 3.0. The build failed complaining that NSTask is undeclared. Based on release notes for iPhone OS 3.0, I got to know that NSTask has been removed from the Foundation framework among several other API’s with iPhone OS 3.0. Moving forward all projects which used NSTask would fail n would require some amount of recoding to fill the missing gaps.