Showing posts with label iPad. Show all posts
Showing posts with label iPad. Show all posts

Monday, 1 October 2012

The Social Framework - Makes the iPhone/iPad App Simple in Facebook and Twitter Posting


Hi All,

For easy sharing of content including images and url's with Facebook, Twitter and Sina Weibo(I am not familiar with this). iOS 6 provides a new framework named Social. 

Now a days in most of the iOS app had a required functionality to share some content in Facebook / Twitter to increase the app acceptability and as advertisement. For achieving this by a formal method the developer has to code separate set of classes to achieve oAuth for each one for Facebook and other for Twitter, as each had their own framework and the developer need to use those classes to communicate with. but for a developer perspective it is very much extravaganza for a simple sharing.

Now everything ends, apple provide a framework for both, effort is very much less and QA effort is also less. cheers Apple!!!!

To Integrate the Facebook / Twitter / SinaWeibo

First add social framework to project.



And import the framework as follows in the class needed to invoke the share action.

#import <Social/Social.h>

Create a SLComposeViewController object with the service type required,

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

Service type available are,

SLServiceTypeTwitter
SLServiceTypeFacebook
SLServiceTypeSinaWeibo

Then we can set the content to share,
- (BOOL)setInitialText:(NSString *)text;
- (BOOL)addImage:(UIImage *)image;
- (BOOL)addURL:(NSURL *)url;

Setting of parameters can be done before the view is presented.

Present the view when needed,
[self presentViewController:controller animated:YES completion:nil];





In iOS6 there is an option to login the Facebook and Twitter if not logged then when a SLComposeView is present it show an alert to tell the user to login.


cheers!!!!

if you need more details feel free to contact me 

thanks,
Naveen Shan

Thursday, 24 May 2012

The iTunesArtwork in iOS Apps


The Artwork need to do by every iOS Developer

Hi All,

Please make sure that we add "iTunesArtwork" image in every iOs App that we did.
It is used to show in iTunes  when an IPA is synced with device.




What we need to do.
1. Create a 512 * 512 PNG image .
2. Named it as "iTunesArtwork" . Remember iOS device is case-sensitive and note there is no extension for the image.
3. Add this image to application bundle.

NB : We can reuse this image as large icon required while submitting the app to app-store.

Also as a developer it is good enough to ensure the application contains all the icons with specified size.

Icon Required For iPhone/iPod and its Naming Convention and the place where it shows

1. Normal Icon  : 57 * 57  - (icon.png) - inside spring board.
2. Normal Icon (Retina display)  : 114 * 114  - (icon@2x.png) - inside spring board when retina display enabled.
3. App icon for the App Store (iTunesArtwork) :  512 * 512 - (iTunesArtwork) - inside iTunes and App-store.
4. App icon for the App Store (iTunesArtwork) (Retina display) :  1024 * 1024 - (iTunesArtwork@2x) - inside iTunes and App-store when retina display enabled.
5. Small icon for Spotlight search results and Settings : 29 * 29 - (icon-Small.png) - inside iPhone Search and Settings.
6. Small icon for Spotlight search results and Settings (Retina display) : 58 * 58 - (icon-Small@2x.png) - inside iPhone Search and Settings when retina display enabled.
7. Launch Image : 320 * 480 - (Default.png) - show while app launching.
8. Launch Image (Retina display) : 640 * 960 - (Default@2x.png) - show while app launching when retina display enabled.

Icon Required For iPad and its Naming Convention and the place where it shows

1. Normal Icon  : 72 * 72  - (icon.png) - inside spring board.
       if it is a universal app name the icon as (icon-Large.png).
2. Normal Icon (Retina display)  : 114 * 114  - (icon@2x.png) - inside spring board when retina display enabled.
       it is same as in case for iPhone/iPod.
3. App icon for the App Store (iTunesArtwork) :  512 * 512 - (iTunesArtwork) - inside iTunes and App-store.
       it is same as in case for iPhone/iPod.
4. App icon for the App Store (iTunesArtwork) (Retina display) :  1024 * 1024 - (iTunesArtwork@2x) - inside iTunes and App-store when retina display enabled.
        it is same as in case for iPhone/iPod.
5. Small icon for Settings : 29 * 29 - (icon-Small.png) - inside iPad Settings.
6. Small icon for Settings (Retina display) : 58 * 58 - (icon-Small@2x.png) - inside iPad Settings when retina display enabled.
7. Small icon for Spotlight search results : 50 * 50 - (icon-Small~ipad.png)  - inside iPad Search.
8. Small icon for Spotlight search results (Retina display) : 100 * 100 - (icon-Small~ipad@2x.png)  - inside iPad Search when retina display enabled.
9. Launch Image Portrait : 768 * 1004 - (Default-Portrait~ipad.png) - show while app launching in portrait orientation.
10. Launch Image Portrait (Retina display) : 1536 * 2008 - (Default-Portrait~ipad@2x.png) - show while app launching in portrait orientation when retina display enabled.
11. Launch Image Landscape : 1024 * 748 - (Default-Landscape~ipad.png) - show while app launching in landscape orientation.
12. Launch Image (Retina display) : 2048 * 1496 - (Default-Landscape~ipad@2x.png) - show while app launching in landscape orientation when retina display enabled.

NB : if we follow the naming convention I specified above then there is no need to specify the icons in application info-plist and also it helps to support the older iOS versions.

So In short,
iPhone app requires : 8 images
iPad app requires     : 12 images
And Universal iOS app requires : 15 images


if we ensure this much of images is added in application then a normal user thinks your application uses nice graphics till he/she launch your app.

if you need more details feel free to contact me

thanks,
Naveen Shan

Tuesday, 13 March 2012

Monitor Network Status and Network Type in iOS


Hi All,

In most of the iOS application which uses server and server api's wants to a check whether network is available at any moment when application runs.
we all know how to check the network status (Using Apple's Reachability code we can check the network status by pinging to a hosted server).
But some cases instead of checking for network is available we need to get/alert about network status change and the network type change.

So here I got up with an implementation of a custom class that will alert the network status change.


//To get the Network Status/ Change in Network Type with NSNetworkMonitor,
(Here prefix NS means not 'Next Step' it just 'Naveen Shan' my name, if you don't like change it.)

1. Initialize the Network Monitor on App Launch.

 //for monitoring network connectivity  
 [NSNetworkMonitor initializeNetworkMonitor];  

2. To Catch the Network Status implement the following Notification.

 //to catch network status.  
 [[NSNotificationCenter defaultCenter] addObserver:self  
                      selector:@selector(changeInNetworkConnection:)  
                        name:KNETWORKNOTIFIER  
                       object:nil];  

3. The Response Method is implemented as follows,

 -(void)changeInNetworkConnection:(NSNotification *)notification {  
   NSDictionary *status = [notification object];  
   if ([[status objectForKey:@"NetworkAvailable"] boolValue]) {  
     NSLog(@"The NetworkConnection StatusDidChanged : NO Connection");  
   }  
   else  {  
     if ([[status objectForKey:@"NetworkType"] isEqualToString:@"WiFi"]) {  
       NSLog(@"The NetworkConnection StatusDidChanged : wifi Connection");  
     }  
     else  {  
       NSLog(@"The NetworkConnection StatusDidChanged : wann Connection");  
     }  
   }  
 }  

Some Helper Methods

 +(BOOL)isNetWorkConnectionAvailable;  
 +(NetworkAvailable)currentNetwork;  

One Important Tip

- we get a network change notification on app launch when the network status is changed while app is in minimize stage.

Dependencies

- Need to add Apple's Reachability Classes.
- Need to add SystemConfiguration.framework.

I attached Complete code here

if you need more details feel free to contact me

thanks,
Naveen Shan

Friday, 3 February 2012

Arrowed Title View


Hi All,

I Found that in lot of application specifically in case of iPad with complex view design sometimes we use arrow to a specific location to pointing out the user what to do, most developers use image(arrowed image) for this purpose with a label over it. But I think if we use a subclass of UIView is less weight, so I go through the drawing tutorials and create my on view. I use it in my two different projects.

In this example code I attached herewith shows the arrow at bottom left corner, but any one can change the location very easily.

Now (while posting this blog), I think it is better to had the view in such a way that the arrow position is changeable from external interface, But now I don't have time so I will post another blog or update this blog later for this. (I mean I try to implement Arrowed title view with arrow can be at any location around the view like the UIPopover arrow setting).

See the screen Shots,




//To Display the Arrowed Title View named as NSArrowedTitleView
(Here prefix NS means not 'Next Step' it just 'Naveen Shan' my name, if you don't like change it.)

 -(void)showTitleView {  
   NSArrowedTitleView *objTitleView = [[NSArrowedTitleView alloc] initWithFrame:CGRectMake(0, 20, (self.view.frame.size.width), 40)];  
   objTitleView.viewColor = [UIColor grayColor];  
   objTitleView.viewTitle = @"NSArrowed Title View";  
   [objTitleView setNeedsDisplay];  
   [self.view addSubview:objTitleView];  
   [objTitleView release];  
   objTitleView = nil;  
 }  

2. call the above method like as follows,

 [self showTitleView];  

I attached complete code here

if you need more details feel free to contact me

thanks,
Naveen Shan

Tuesday, 31 January 2012

Customized UIAlertView to Input Credential


Hi All,

I Found lot of UIAlertView customization but I cannot able to find a nice one to take credential input, I need such alert view for an NTLM authentication for a web service I called in my recent project. It is mainly due to in browser itself NTLM credential is input using a alert popup and my customer also requires it.
so I search over google and I got lot of samples but no one matches some of my requirement so I write my own customized UIAlertView with following specialities,

1. It support multiple line for title and message and it will 'word' wrapped the text.
2. As in case of ordinary UIAlertView if message is too big it will add to a UITextView instead of a label, I overcome it.
3. Set the frame of AlertView as per the text length.
4. Label size is align with Text (Word wrapping of text with correct alignment to top left).
5. Support for iOS3.2 and above including iOS5.0.
6. Handle proper display and dismiss of keyboard with Next action.
7. Support for iPhone and iPad with orientation.

See the following Screen Shots,






//To Display the Customized UIAlertview named as NSAuthAlertView
(Here prefix NS means not 'Next Step' it just 'Naveen Shan' my name, if you don't like change it.)

1. Paste this function in the class you wish to call,

 + (void)showCredentialInputAlert:(NSString *)alertTitle message:(NSString *)strAlertMessage delegateObject:(id)delegate viewTag:(int)iTag  {  
   NSAuthAlertView *alertView;  
   @try {  
     alertView=[[NSAuthAlertView alloc] initWithTitle:alertTitle message:strAlertMessage delegate:delegate viewTag:iTag];  
     [alertView show];  
     [alertView release];  
     alertView  =  nil;  
   }  
   @catch (NSException * exception) {  
     NSLog(@"Exception on showCredentialInputAlert : %@",[exception description]);  
   }  
   @finally {  
     [alertView release];  
     alertView  =  nil;  
   }  
 }  

2. call the above method like as follows,

 [[self class] showCredentialInputAlert:@"NSAuthAlertView" message:[NSString stringWithFormat:@"Enter Credentials for Login"] delegateObject:self   
 viewTag:KAUTHENTICATEALERTTAG];  

3. As a best practice you need to define tag value,
 #define KAUTHENTICATEALERTTAG 12131415  

//To catch the response (Username and Password) form NSAuthAlertView

1. Paste the following alert view delegate,

 #pragma mark - UIAlertView delegate  
 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {  
   if (alertView.tag == KAUTHENTICATEALERTTAG) {  
     if (buttonIndex == 1)  {  
       NSString *username = ((UITextField *)[alertView viewWithTag:(KAUTHENTICATEALERTTAG + 1)]).text;  
       NSString *password = ((UITextField *)[alertView viewWithTag:(KAUTHENTICATEALERTTAG + 2)]).text;  
       if (username && password)  {  
         //validation of credential is done here.  
         //[self validCredential];  
       }  
       else     {  
         //empty credential.  
       }  
     }  
     else if (buttonIndex == 0) {  
     }  
   }  
 }  

I attached complete code here

if you need more details feel free to contact me

thanks,
Naveen Shan