Tuesday, 15 October 2013

Use Mapkit framework to create a custom annotation view over map view



To create a custom annotation view over map view  using  Mapkit framework just follow these simple steps.


Step 1- While adding annotation don’t give its title and subtitle. Just add it with Latitude / Longitude and take an integer variable that starts with 100(so that its tag do not clash with others) and increases as per the loop for adding notation.

annotationTag = 100;

for(NSDictionary* postLocateDict in mapData ) {
       
        double lat = [[postLocateDict objectForKey:@"location_dx"] doubleValue];
        double longt = [[postLocateDict objectForKey:@"location_dy"] doubleValue];
       
CLLocationCoordinate2D loc;
        loc.longitude = longt;
        loc.latitude = lat;
       
        MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
       
       
        annotationPoint.coordinate = loc;
        [mapViewHuanBao addAnnotation:annotationPoint];
        annotationTag++;
    }


Step 2- When you add a notation this will call an MKMapViewDelegate function, just set a tag of that notation.

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
   
    if([annotation isKindOfClass:[MKUserLocation class]]) {
        return nil;
    }
    static NSString *identifier = @"myAnnotation";
    MKAnnotationView * annotationView = (MKAnnotationView *)[self.mapViewHuanBao dequeueReusableAnnotationViewWithIdentifier:identifier];
    if (!annotationView)
    {
        annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
       
        annotationView.image = [UIImage imageNamed:@"pin.png"];
    }else {
        annotationView.annotation = annotation;
    }
    annotationView.tag = annotationTag;
   
    return annotationView;
}


Step 3 – When you tap on notation, a delegate function will call where you can identify the notation by its tag.

(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view

Here you will identify the notation by its tag using following code-

NSInteger indexOfTheObject = [mapView.annotations indexOfObject:view.annotation];

In indexOfTheObject you will get the notation tag.

Step 4- Now create a custom view as per your requirement, and give tag to every property you used in that view. We used callout view name as calloutView.

Set its file owner to your view controller.






Step 5- After finding the tag of selected notation, just use following method to create a custom call out view.

  [[NSBundle mainBundle] loadNibNamed:@"calloutView" owner:self options:nil];
       
        CGPoint hitPoint = [view convertPoint:CGPointZero toView:mapView];
        [annotationView2 setFrame:CGRectMake(hitPoint.x-94,hitPoint.y-73, 220, 73)];
        annotationView2.tag = selectedAnnotation;
       
        UILabel *nameLbl = (UILabel *)[annotationView2 viewWithTag:[here give ur tag which u set in custom view]];

And so on....

Step 6- Finally just add it to the view.


[view addSubview:annotationView2];




You can also navigate it to its detail but for that you have to add it on map view, because when you are adding it on view it will remove it from view, so the object  is DE allocated.

We are working on its navigation on click while moving ,  comment here if you found any problem.
 

Monday, 14 October 2013

Dussehra Celebration @Singsys Lucknow Office

Dussehra (Vijaya Dashami, Dasara, or Dashain) is a Hindu festival that celebrates the victory of good over evil.


Team Singsys celebrated Dussehra this year in unique way with a theme "AAJ KAA RAVAN" to symbolic burning of all the evils and victory of truth over evil.

Tuesday, 8 October 2013

Weekly Technology Tip : How to make connection with database in a C# window based application using App.config file





Creating a database connection string from app.config is a very common practice used in C# windows based application. Follow these simple steps to make connection with database in C# window based application using App.config file.

Step1. Open Visual Studio and create a new Windows application. (Path : Start -> All Programs -> Microsoft Visual Studio 2010-> Microsoft Visual Studio 2010)


Step2. Add a new Application Configuration file App.config file to the project.

 
Step3. Provide the connection string name, database name and system related information in the App.config file.


<configuration>
  <connectionStrings>
    <add name="customConnection" connectionString="Data Source=Custom-PC;Initial Catalog=customDB;User Id=sa;Password=" providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>


Step4.  Making a separate connection class. 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
namespace customproject
{
    public class Class_custom
    {

        public SqlConnection con ;
        public SqlCommand cmd;
        public Class_custom()
        {
            con = new SqlConnection(ConfigurationManager.ConnectionStrings["customConnection "].ConnectionString);
            con.Open();
            cmd = new SqlCommand();
            cmd.Connection = con;
        }
    }
   
}


Using above code, the user can make connection with database in a C# window using App.config file.



Singsys is Singapore based custom website design, web applications 
and mobile application development company. Services include Website, 
Android Apps, iPhone and iPad Apps, CMS based websites using Drupal,
Joomla and Wordpress, Ecommerce solutions based on Magento,
Virtuemart, Ubercart, Prestashop and OSCommerce. Call us at +65-65613900 or email to
 info@singsys.com

Monday, 7 October 2013

Web Design and Web Development in Singapore


Having a good-looking and attractive professional website is a key to success for every small business owners. A well design and maintained website is important for all kind of business. Having a website for your business is best method for your users and visitors to find you. With a website, business owners can generate direct and viral traffic from people who want to know more about their products and services.

Web Design Company in Singapore provide custom web design services matching the customer needs and other web services with our professional touch to the web design. In this fast growing market, your website needs to be outstanding and must work on all kind of browsers. Our CSS experts use responsive web design techniques where your website will look equally great on iPad, iPhone, Android phones and tablets. That is the beauty of responsive theme design and coding by Singsys's experts. All our website comes with a CMS system so that you do not end looking for your website designer in middle of the night to add that new announcement you want your visitors to see when they wake up in morning. We provide all kind of web design services ranging from very simple to very complex web services.

For any assistance, please contact us and email us at info@singsys.com or give us a call on +65-65613900.

Learn important web design tip to boost your SEO efforts.

Friday, 4 October 2013

Weekly Technology Tip - "How to maintain android checkbox state after scrolling"


The getView() method of the class extending the BaseAdapter holds the state of the currently displayed view which is invalidated when scrolling the listview. So, in order to avoid this problem, proceed in the following manner:-

• Create a nested class within the class (class which is extending BaseAdapter Class), namely, Viewholder.

• Declare all the views of an individual list item in this Viewholder Class.

• Create an object of this Viewholder class in the getView() method and initialize all the views declared in the Viewholder class using this object.

See an example on How to maintain the state of the checkbox in list-view when scrolling it in Android use BaseAdapter