-(BOOL)automaticallyAdjustsScrollViewInsets{
return NO;
}
Monday, 31 March 2014
Fix blank space at top of UITextView in iOS 7
Saturday, 29 March 2014
Loading Table view Cell image form URL
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0) , ^{
NSData *imgData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"Image url here"]];
if (imgData) {
UIImage *image = [UIImage imageWithData:imgData];
if (image) {
dispatch_async(dispatch_get_main_queue(), ^{
MyCustomCell *cell = (id)[tableView cellForRowAtIndexPath:indexPath];
if (cell)
cell.myCellImgView.image=image;
});
}
}
});
Wednesday, 26 March 2014
@Property Attributes
Attribute | Description |
---|---|
getter= | Use a custom name for the getter method. |
setter= | Use a custom name for the setter method. |
readonly | Don’t synthesize a setter method. |
nonatomic | Don’t guarantee the integrity of accessors in a multi-threaded environment. This is more efficient than the default atomic behavior. |
strong | Create an owning relationship between the property and the assigned value. This is the default for object properties. |
weak | Create a non-owning relationship between the property and the assigned value. Use this to prevent retain cycles. |
copy | Create a copy of the assigned value instead of referencing the existing instance. Reference |
Monday, 24 March 2014
NULL and nil
- The null pointer is a special kind of pointer that doesn’t point to anything.
- Pointer can be “emptied” using the null pointer.
- A good rule of thumb is to use nil for variables that hold Objective-C objects and NULL when working with C pointers.
NSString *anObject; // An Objective-C object anObject = NULL; // This will work anObject = nil; // But this is preferred int *aPointer; // A plain old C pointer aPointer = nil; // Don't do this aPointer = NULL; // Do this instead
Monday, 3 March 2014
Find Longitude and Latitude From Address String
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
NSString *addressString =@"Apple Inc";
[geocoder
geocodeAddressString:addressString
completionHandler:^(NSArray *placemarks,
NSError *error) {
if (error) {
NSLog(@"Geocode failed with error: %@", error);
return;
}
if (placemarks && placemarks.count > 0)
{
CLPlacemark *placemark = placemarks[0];
CLLocation *location = placemark.location;
NSLog(@"latitude = %f longitude = %f",location.coordinate.latitude , location.coordinate.longitude);
}
}];
Location Details From latitude and longitude
CLLocation *location=[[CLLocation alloc] initWithLatitude:48.8582 longitude:2.2945];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
if(placemarks.count){
NSDictionary *addressDictionary = [[placemarks objectAtIndex:0] addressDictionary];
NSLog(@"Address%@",addressDictionary);
}
}];
Setting Region and Annotation in Map View for a coordinate
//Create a coordianate
CLLocationCoordinate2D coordinate= CLLocationCoordinate2DMake(37.785834,-122.406417);
//Set region for with the coordiante
MKCoordinateRegion region =MKCoordinateRegionMakeWithDistance(coordinate, 800, 800);
[self.mapView setRegion:[self.mapView regionThatFits:region] animated:YES];
//add point annotaion to map view
MKPointAnnotation *point=[[MKPointAnnotation alloc] init];
point.coordinate=coordinate;
point.title=@"hai I am here!!";
point.subtitle=@"hey how are you?";
[self.mapView addAnnotation:point];
Saturday, 1 March 2014
Subscribe to:
Posts (Atom)