tableCell usng Drag And Drop

view.h


#import <UIKit/UIKit.h>





@interface ViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property NSArray *ary,*image;

@end

view.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.ary=[[NSMutableArray alloc]initWithObjects:@"mahesh",@"surya",@"nagarjuna",@"salman", nil];
    self.image=[NSMutableArray arrayWithObjects:@"mahesh.jpeg",@"surya.jpeg",@"naga.jpg",@"salman.jpeg", nil];
    // Do any additional setup after loading the view, typically from a nib.
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.ary count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *identifier=@"id";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    cell.textLabel.text=[self.ary objectAtIndex:indexPath.row];
    cell.imageView.image=[UIImage imageNamed:[self.image objectAtIndex:indexPath.row]];
    return cell;
   
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
Previous
Next Post »