Pages

Sunday, April 17, 2011

iphone: Remember always small thing second


  • 1.     Compare Null value that come from net.
  • 2.     Image load from web.
  • 3.     Navigate view from bottom.
  • 4.     To dismiss this view.
  • 5.  Get UDID of Apple Device.
  • 6.     TAB base Application to come tab page instance of last visited page.
  • 7.     Make Back Button on New Page rather with Back Name.
  • 8.     Able Cancel button of ActionSheet on tab bar.
  • 9.     Get Array from NSString.
  • 10. How to make Shadow on UiLable. 
  • 11. How to make image Corner round. 



Compare Null value that come from net:

if([[[data objectForKey:@"pic"] description] isEqualToString:@""])

or

if([data objectForKey:@"pic"] != [NSNull null])

Image load from web:

 NSData *receivedData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:URL]];
 UIImage  *image  = [[UIImage alloc] initWithData:receivedData] ;

Navigate view from bottom:
[self presentModalViewController:ObjChatting animated:YES];


To dismiss this view:
if(self.navigationController == nil)
          [self dismissModalViewControllerAnimated:YES];

Get UDID of Apple Device:
NSString *udid = [[UIDevice currentDevice] uniqueIdentifier];

NOTE: we can get other detail from UIDevice class.

TAB base Application to come tab page instance of last visited page:

- (void)viewDidDisappear:(BOOL)animated
{          
    if(self.navigationController.visibleViewController==self)
    {
      [self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex:0] animated:YES];
    }      
}

Make Back Button on New Page rather with Back Name:
 UIBarButtonItem  *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"Back" style: UIBarButtonItemStyleBordered target: nil action: nil];
 [[self navigationItem] setBackBarButtonItem: newBackButton];
[newBackButton release];

 NOTE: Use in viewDidLoad in first page from where you write push statement.

Able Cancel button of ActionSheet on tab bar:

[actionSheet showInView:self.tabBarController.view];

NOTE: use when cancel button come over tabbar. (In this situation, cancel button will not work)

Get Array from NSString:

NSArray *arr = [str componentsSeparatedByString:@"\n"];

where str is @"One \n two \n three"

NOTE: Avoid to use NSMutableString, i had problem


How to make Shadow on UiLable:
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
or
lblname.shadowColor = [UIColor whiteColor];
with
lblname.shadowOffset = CGSizeMake(0.0, 1.0);

How to make image Corner round. 
For Button:
btnbottom4.imageView.layer.cornerRadius=15.0;
btnbottom4.imageView.layer.borderWidth=0.0;
btnbottom4.imageView.layer.borderColor=[[UIColor clearColor] CGColor];
For ImageView:
imageView.layer.cornerRadius=15.0; imageView.layer.borderWidth=0.0; imageView.layer.borderColor=[[UIColor clearColor] CGColor];













No comments:

Post a Comment