table

tbl.estimatedRowHeight = 100.0;
// tbl.rowHeight = UITableViewAutomaticDimension;

//
// ViewController.m
// tbl_cell_height
//
// Created by Devlon on 6/22/15.
// Copyright (c) 2015 Devlon. All rights reserved.
//

#import “ViewController.h”
@interface ViewController ()
{
NSIndexPath *selectedCellIndexPath;
int t;
int selectedNumber;
NSIndexPath *_expandIndexPath;
}
@end

@implementation ViewController

– (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

– (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

– (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10.
;
}

– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@”c1″];
if (cell == nil)
{
cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@”c1″];
}
return cell;
}

– (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([indexPath isEqual:_expandIndexPath])
return 80;

return 44;
}

– (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

// NSMutableArray *modifiedRows = [NSMutableArray array];
// // Deselect cell
// [tableView deselectRowAtIndexPath:indexPath animated:TRUE];
// _expandIndexPath = indexPath;
// [modifiedRows addObject:indexPath];
//
// // This will animate updating the row sizes
// [tableView reloadRowsAtIndexPaths:modifiedRows withRowAnimation:UITableViewRowAnimationAutomatic];
}

@end

extraa

How to make dynamic button with Game

– (void)viewDidLoad

{

[super viewDidLoad];

xaxis = 20,yaxis=100,index=1;

for (int y = 0; y<4; y++)

{

for (int x=0; x<4; x++)

{

btn1 =[UIButton buttonWithType:UIButtonTypeRoundedRect];

btn1.frame=CGRectMake(xaxis, yaxis, 50, 50);

btn1.backgroundColor=[UIColor redColor];

[btn1 addTarget:self action:@selector(btnclick:) forControlEvents:UIControlEventTouchUpInside];

xaxis = xaxis + 70;

btn1.tag=index;

index++;

[self.view addSubview:btn1];

}

yaxis=yaxis+70;

xaxis=20;

}

randm = (arc4random()%16+1);

btn1 =(UIButton *)[self.view viewWithTag:randm];

btn1.backgroundColor=[UIColor blueColor];

}

-(IBAction)btnclick:(UIButton *)sender

{

if (sender.tag == randm)

{

count++;

sender.backgroundColor=[UIColor brownColor];

sender.enabled=false;

if (count == 16)

{

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@”Game Overr” message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@”ok”, nil];

[alert show];

}

else

{

BOOL flag=true;

while (flag)

{

randm = (arc4random()%16+1);

btn1 = (UIButton *)[self.view viewWithTag:randm];

if (btn1.enabled) {

btn1.backgroundColor=[UIColor blueColor];

flag=false;

}

}

}

}

}

How to make dynamic button with Game

– (void)viewDidLoad

{

[super viewDidLoad];

xaxis = 20,yaxis=100,index=1;

for (int y = 0; y<4; y++)

{

for (int x=0; x<4; x++)

{

btn1 =[UIButton buttonWithType:UIButtonTypeRoundedRect];

btn1.frame=CGRectMake(xaxis, yaxis, 50, 50);

btn1.backgroundColor=[UIColor redColor];

[btn1 addTarget:self action:@selector(btnclick:) forControlEvents:UIControlEventTouchUpInside];

xaxis = xaxis + 70;

btn1.tag=index;

index++;

[self.view addSubview:btn1];

}

yaxis=yaxis+70;

xaxis=20;

}

randm = (arc4random()%16+1);

btn1 =(UIButton *)[self.view viewWithTag:randm];

btn1.backgroundColor=[UIColor blueColor];

}

-(IBAction)btnclick:(UIButton *)sender

{

if (sender.tag == randm)

{

count++;

sender.backgroundColor=[UIColor brownColor];

sender.enabled=false;

if (count == 16)

{

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@”Game Overr” message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@”ok”, nil];

[alert show];

}

else

{

BOOL flag=true;

while (flag)

{

randm = (arc4random()%16+1);

btn1 = (UIButton *)[self.view viewWithTag:randm];

if (btn1.enabled) {

btn1.backgroundColor=[UIColor blueColor];

flag=false;

}

}

}

}

How to make timer

– (IBAction)Start:(id)sender

{

[time1 invalidate];

time1 = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(onTick) userInfo:Nil repeats:YES];

}

– (void)onTick

{

count++;

NSString *ts = [[NSString alloc]initWithFormat:@”%d”,count ];

_lbl1.text= ts;

}

– (IBAction)stop:(id)sender

{

if ([time1 isValid])

{

[time1 invalidate];

//count=0; // using this two line direct set 0 & satrt with 0

// _lbl1.text=@”0″;

NSString *ts = [[NSString alloc]initWithFormat:@”%d”,count ];

_lbl1.text= ts;

}

// time1 = nil;

}

}

popoverrr

-(IBAction)prsn_click:(id)sender

{

    NSLog(@”hello click”);

    

    [[NSNotificationCenter defaultCenter] addObserver:self

                                             selector:@selector(relod_ful:)

                                                 name:@”SecondViewControllerDismissed”

                                               object:nil];

    if (UI_USER_INTERFACE_IDIOM() ==UIUserInterfaceIdiomPhone)

    {

        view_popover *vp=[self.storyboard instantiateViewControllerWithIdentifier:@”view_popover”];

        [self presentViewController:vp animated:YES completion:nil];

        

    }

    else

UIPopoverController *po,* po1,*po2;

    {

        view_popover *vp=[self.storyboard instantiateViewControllerWithIdentifier:@”view_popover”];

        [app.po1 dismissPopoverAnimated:YES];

        app.po=[[UIPopoverController alloc]initWithContentViewController:vp];

        

        

        

        [app.po presentPopoverFromBarButtonItem:editBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

        }

   }

extra

Convert NSArray to swift Array

  • IQKeyboardManager.swift
  • IQKeyboardReturnKeyHandler.swift
  1. Need to Convert NSMutableSet to swift Array
  • IQNSArray+Sort.swift
  1. Need to replace with Array extension
  • IQUIView+Hierarchy.swift
  1. Need to fix _IQDescription() method.
  2. Need to convert NSArray to swift Array
  • IQUIWindow+Hierarchy.swift
  • IQKeyboardManagerConstants.swift
  • IQKeyboardManagerConstantsInternal.swift
  • IQTextView.swift
  • IQBarButtonItem.swift
  • IQTitleBarButonItem.swift
  • IQToolbar.swift
  • IQUIView+IQKeyboardToolbar.swift

http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout

http://www.raywenderlich.com/64546/introduction-to-cocoapods-2

http://www.raywenderlich.com/64392/video-tutorial-beginning-auto-layout

http://www.raywenderlich.com/video-tutorials#tableview

http://blog.dadabeatnik.com/2013/11/01/parsing-json-in-ios/

http://code.tutsplus.com/tutorials/ios-sdk-working-with-url-schemes–mobile-6629

http://useyourloaf.com/blog/2010/10/19/searching-arrays-with-nspredicate-and-blocks.html

http://rypress.com/tutorials/objective-c/data-types/nsarray

http://kerkermeister.net/objective-c-adapter-from-nsinteger-to-id-when-using-performselector-withobject/

http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout

http://www.raywenderlich.com/64546/introduction-to-cocoapods-2

http://www.raywenderlich.com/64392/video-tutorial-beginning-auto-layout

http://www.raywenderlich.com/video-tutorials#tableview

http://blog.dadabeatnik.com/2013/11/01/parsing-json-in-ios/

single checkmark select value still not go in tableview

NSIndexPath *selectedCell;

– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    UITableViewCell *cell=[tbl_pro dequeueReusableCellWithIdentifier:@”K1″];

    if (cell==nil)

    {

        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@”K1″];

        

    }

    cell.textLabel.text=[arr_main objectAtIndex:indexPath.row];

    if (indexPath.row == l1)

    {

        selectedCell=indexPath;

        cell.accessoryType=UITableViewCellAccessoryCheckmark;

    }

    else

    {

        cell.accessoryType=UITableViewCellAccessoryNone;

    }

    return cell;

}

– (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

//     UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];

//    if (t == 0)

//    {

//        cell.accessoryType = UITableViewCellAccessoryNone;

//        t=5;

//    }

//    

//   

//

// //   cell.accessoryType=UITableViewCellAccessoryNone;

//    if (cell.accessoryType == UITableViewCellAccessoryCheckmark)

//    {

//        cell.accessoryType=UITableViewCellAccessoryNone;

//    }

//    else

//    {

//         cell.accessoryType=UITableViewCellAccessoryCheckmark;

//    }

    UITableViewCell *previouscell=[tableView cellForRowAtIndexPath:selectedCell];

    

    UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];

    

    if(cell.selected)

    {

        l1 =indexPath.row ;

        NSLog(@”%d”,l1);

        previouscell.accessoryType = UITableViewCellAccessoryNone;

        cell.accessoryType = UITableViewCellAccessoryCheckmark;

    }

    else

    {

        

        cell.accessoryType = UITableViewCellAccessoryNone;

        

    }

}

map pin multiple

#import <MapKit/MapKit.h>

MKMapViewDelegate,CLLocationManagerDelegate

-(void)mappin

{

    NSLog(@”%lu”,(unsigned long)app.arr_main_data.count);

    NSLog(@”%lu”,(unsigned long)[[app.arr_main_data valueForKey:@”lat”]count ]);

    CLLocationCoordinate2D loc;

    for (int x=0; x<app.arr_main_data.count; x++)

    {

        loc.latitude=[[[app.arr_main_data valueForKey:@”lat”] objectAtIndex:x]doubleValue];

        loc.longitude=[[[app.arr_main_data valueForKey:@”long”] objectAtIndex:x]doubleValue];

        

        NSLog(@”%f”,loc.latitude);

        MKPointAnnotation *myano =[[MKPointAnnotation  alloc]init];

        

        

        

        myano.coordinate=loc;

        // NSString *str_ttl=[arr_get_title objectAtIndex:x];

        NSString *strr_cityname = [[app.arr_nme objectAtIndex:x] stringByReplacingOccurrencesOfString:@”Testing –” withString:@””];

        

        myano.title=strr_cityname;

        

        

        MKCoordinateRegion adjustedRegion = [map regionThatFits:MKCoordinateRegionMakeWithDistance(loc, 1000, 1000)];

        adjustedRegion.span.longitudeDelta  = 0.02;

        adjustedRegion.span.latitudeDelta  = 0.02;

        

        [map setRegion:adjustedRegion animated:YES];

        

        [map addAnnotation:myano];

        map.centerCoordinate=loc;

        

        

        

    }

    

    //  [mymap_all addAnnotation:myano];

    //   mymap_all.centerCoordinate=loc;

    [map showsUserLocation];

    

}

– (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {

    // if its the user location, just return nil

    if ([annotation isKindOfClass:[MKUserLocation class]])

        return nil;

    

    // Try to dequeue an existing pin view first

    static NSString *AnnotationIdentifier =@”AnnotationIdentifier”;

    MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];

    pinView.pinColor = MKPinAnnotationColorPurple;

    pinView.animatesDrop = YES;

    pinView.canShowCallout = YES;

    

    // UIButton *detailbtn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

    //NSInteger annotationValue = annotation

    

    [rightButton addTarget:self action:@selector(map_tag_click:) forControlEvents:UIControlEventTouchUpInside];

    rightButton.tag=lol;

    NSLog(@”%ld”,(long)rightButton.tag);

    

    //[rightButton addTarget:self action:@selector(showDV:) forControlEvents:UIControlEventTouchUpInside];

    pinView.rightCalloutAccessoryView = rightButton;

    

    

    

    return pinView;

}

-(IBAction)map_tag_click:(UIButton *)sender

{

    /* NSLog(@”%ld”,(long)sender.tag);

     NSLog(@”%@”,[arr_get_title objectAtIndex:sender.tag]);

     NSString *strrr=[arr_get_slug objectAtIndex:sender.tag];

     

     NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@”http://corporateletting.com/?json=get_post&post_type=ad_listing&slug=%@“,[strrr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];

     NSLog(@”%@”,url);

     NSURLRequest *req =[[NSURLRequest alloc]initWithURL:url];

     NSError *err;

     NSURLResponse *res;

     NSData *d1 =[NSURLConnection sendSynchronousRequest:req returningResponse:&res error:&err];

     NSDictionary *dict =[NSJSONSerialization JSONObjectWithData:d1 options:NSJSONReadingAllowFragments error:&err];

     app.bthview_Arry_Prti=[dict valueForKey:@”post”];

     NSLog(@”%@”,app.bthview_Arry_Prti);

     PropertyDetailView *pdv =[self.storyboard instantiateViewControllerWithIdentifier:@”PropertyDetailView”];

     [self.navigationController pushViewController:pdv animated:YES];

     */

}

-(void)showdetail:(NSInteger)number

{

    NSLog(@”%ld”,(long)number);

    NSLog(@”%@”,[app.arr_nme objectAtIndex:number]);

    NSString *strrr=[app.arr_nme objectAtIndex:number];

    NSString *str_id=[[app.arr_main_data valueForKey:@”id”]  objectAtIndex:number];

    NSLog(@”%@”,strrr);

    NSLog(@”%@”,str_id);

    app.main_tnt=10;

    

//    NSString *urlstring = [NSString stringWithFormat:@”http://corporateletting.com/?json=get_post&post_type=ad_listing&slug=%@“,[strrr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

    

    NSString *urlstring=[NSString stringWithFormat:@”http://webapi.bonappetitcard.com/api/api.php?method=Get_Restaurants&restaurant_id=%@&#8221;,[str_id stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

//

    NSLog(@”%@”,urlstring);

    

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

    

    

    manager.requestSerializer = [AFJSONRequestSerializer serializer];

    manager.responseSerializer = [AFJSONResponseSerializer serializer];

    manager.responseSerializer.acceptableContentTypes=[manager.responseSerializer.acceptableContentTypes setByAddingObject:@”text/html”];

    

    [MBProgressHUD showHUDAddedTo:self.view animated:YES];

    

    [manager GET:urlstring parameters:nil

     

     

         success:^(AFHTTPRequestOperation *operation, id responseObject)

     

     {

         [MBProgressHUD hideHUDForView:self.view animated:YES];

         

         NSLog(@”JSON: %@”, responseObject);

         

         NSDictionary   *dict_chk = (NSDictionary *) responseObject;

         

         NSLog(@”dict %@”, dict_chk);

         if ([[dict_chk valueForKey:@”status”] isEqualToString:@”Success”])

         {

          //   NSLog(@”%@”,[[dict_chk valueForKey:@”restaurant_list”] objectAtIndex:0]);

             NSArray *arr12=[[dict_chk valueForKey:@”restaurant_list”]objectAtIndex:0];

             

             app.arr_al1_htl_dtl=[(NSMutableArray *)arr12 objectAtIndex:0];

             NSLog(@”%@”,app.arr_al1_htl_dtl);

           //  NSLog(@”%@”,[app.arr_al1_htl_dtl objectAtIndex:0]);

             view_particular_htl_details *vphd=[self.storyboard instantiateViewControllerWithIdentifier:@”view_particular_htl_details”];

               [self.navigationController pushViewController:vphd animated:YES];

         }

         else

         {

             

         }

         

//         app.bthview_Arry_Prti=[dict_chk valueForKey:@”post”];

//         NSLog(@”%@”,app.bthview_Arry_Prti);

//         PropertyDetailView *pdv =[self.storyboard instantiateViewControllerWithIdentifier:@”PropertyDetailView”];

//         [self.navigationController pushViewController:pdv animated:YES];

         

         

         

     }

         failure:^(AFHTTPRequestOperation *operation, NSError *error)

     {

         UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@”Error Retrieving Weather”

                                                             message:[error localizedDescription]

                                                            delegate:nil

                                                   cancelButtonTitle:@”Ok”

                                                   otherButtonTitles:nil];

         [alertView show];

         

         

         NSLog(@”Error: %@”, alertView);

     }];

    

    

    

    

    

    

    

    

    //     NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@”http://corporateletting.com/?json=get_post&post_type=ad_listing&slug=%@“,[strrr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];

    //     NSLog(@”%@”,url);

    //     NSURLRequest *req =[[NSURLRequest alloc]initWithURL:url];

    //     NSError *err;

    //     NSURLResponse *res;

    //     NSData *d1 =[NSURLConnection sendSynchronousRequest:req returningResponse:&res error:&err];

    //     NSDictionary *dict =[NSJSONSerialization JSONObjectWithData:d1 options:NSJSONReadingAllowFragments error:&err];

    //     app.bthview_Arry_Prti=[dict valueForKey:@”post”];

    //     NSLog(@”%@”,app.bthview_Arry_Prti);

    //     PropertyDetailView *pdv =[self.storyboard instantiateViewControllerWithIdentifier:@”PropertyDetailView”];

    //     [self.navigationController pushViewController:pdv animated:YES];

    

}

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {

    id <MKAnnotation> annotation = [view annotation];

    if ([annotation isKindOfClass:[MKPointAnnotation class]])

    {

        NSLog(@”calloutAccessoryControlTapped: annotation = %@”, view.annotation);

    }

    

    

    

    CLLocationCoordinate2D cd=  [view.annotation coordinate];

    NSNumber *lat = [NSNumber numberWithDouble:cd.latitude];

    [self showdetail:([[app.arr_main_data valueForKey:@”lat”] indexOfObject:[lat stringValue]])];

    

    

    // for (NSString *s  in arr_get_lati) {

    //     NSLog(s);

    // }

    //   UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@”%d”,[arr_get_lati indexOfObject:[lat stringValue]]] message:@”Click Cancel to Go Back” delegate:self cancelButtonTitle:@”Cancel” otherButtonTitles:@”OK”, nil];

    //[alertView show];

    

}

alertview create

– (IBAction)F_pass_btn:(id)sender {

    

    alt=[[UIAlertView alloc]initWithTitle:@”Enter email Id you provided at the time of registration” message:@”Your new password will be sent to this email address.” delegate:self cancelButtonTitle:@”Ok” otherButtonTitles:@”Cancel”, nil];

    alt.alertViewStyle = UIAlertViewStylePlainTextInput;

    alertTextField1 = [alt textFieldAtIndex:0];

    alertTextField1.placeholder = @”Email-Id”;

    

    [alt show];

}

– (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

    if (buttonIndex == 0) {

        NSLog(@”Ok button clicked…”);

        NSURL *url =[NSURL URLWithString:[NSString stringWithFormat:@”http://url/api/api.php?method=forgotpassword&email=%@&#8221;,alertTextField1.text]];

        NSLog(@”%@”,url);

        NSURLRequest *req =[[NSURLRequest alloc]initWithURL:url];

        NSURLResponse *res;

        NSError *err;

        NSData *d2=[NSURLConnection sendSynchronousRequest:req returningResponse:&res error:&err];

        dic_data=[NSJSONSerialization JSONObjectWithData:d2 options:NSJSONReadingAllowFragments error:&err];

        NSLog(@”%@”,dic_data);

        NSString *success=[NSString stringWithFormat:@”%@”,[dic_data objectForKey:@”status”]];

        NSLog(@”%@”,success);

        if ([success isEqualToString:@”Success”])

        {

                        UIAlertView *alert1=[[UIAlertView alloc]initWithTitle:nil message:@”Your new password has been mailed to you.” delegate:nil cancelButtonTitle:@”OK” otherButtonTitles:nil, nil];

            [alert1 show];

            

        }

    }

    else

    {

        

        NSLog(@”Cancel button clicked…”);

        [alt dismissWithClickedButtonIndex:1 animated:YES];

        

    }

}