Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Objective-C, Python, Ruby Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-27-2011, 01:18 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 2
shamsutk87 is on a distinguished road
Default implement Drag and Drop in table view

**I need to implement Drag and Drop in my table view.I have a table View in left side of my screen and i have an image View on right side of an screen.

I need to Drag a image from my table view to right side image view.


let me explain ..

I have an class named as "**myClass**" which contains the properties iD, name and imageURL.

image url holds the photolibrary alasset url.


Code:
**myClass.h**

    @interface myClass: NSObject {
        NSInteger iD;
        NSString *name;
        NSString *imageURL;
    }
    
    @property (nonatomic, assign) NSInteger iD;
    @property (nonatomic, assign) NSString *name;
    @property (nonatomic, assign) NSString *imageURL;

**myClass.m** 

    @implementation myClass
    
    @synthesize iD;
    @synthesize name;
    @synthesize imageURL;
    
    @end
So I added 50 image details with iD, name, imageURL as **myClass** objects in to an NSMutableArray named as **BundleImagesArray **


i displayed it in a table view. my code is:





Code:
  -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section {
        //getting all image details with iD,name,imageURL as **myClass** objects     
        BundleImagesArray = [staticDynamicHandler getImageFromBundle];
                
        int count =  [BundleImagesArray count];
                
        for (int i = 0; i<count; i++) {
            //this array for easy scrolling after first time the table is loaded.
            [imageCollectionArrays addObject:[NSNull null]];
                  
        }
        return count;
            
    }


**cellForRowAtIndexPath**

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {    
     
        static NSString *CellIdentifier = @"Cell";
     
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
    
        //removing all the subviews
        if ([cell.contentView subviews]) {
            for (UIView *subview in [cell.contentView subviews]) {
                [subview removeFromSuperview];
            }
        }
    
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell setAccessoryType:UITableViewCellAccessoryNone];
    
        myClass *temp = [BundleImagesArray objectAtIndex:indexPath.row];
 

        //adding image view 
        UIImageView *importMediaSaveImage=[[[UIImageView alloc] init] autorelease];
        importMediaSaveImage.frame=CGRectMake(0, 0, 200,135 );
        [cell.contentView addSubview:importMediaSaveImage]; 
    
        //adding image label
        UILabel *sceneLabel=[[[UILabel alloc] initWithFrame:CGRectMake(220,0,200,135)] autorelease]; 
        sceneLabel.font = [UIFont boldSystemFontOfSize:16.0];
        sceneLabel.textColor=[UIColor blackColor];
        [cell.contentView addSubview:sceneLabel];
    
        sceneLabel.text = temp.name;
    
        if([imageCollectionArrays objectAtIndex:indexPath.row] == [NSNull null]){ 
    
            //getting photlibrary image thumbnail as NSDAta
            NSData *myData = [self photolibImageThumbNailData::temp.imageURL]
      
            importMediaSaveImage.image =[UIImage imageWithData:myData ];
    
            [imageCollectionArrays replaceObjectAtIndex:indexPath.row withObject:importMediaSaveImage.image];
        } else {
            importMediaSaveImage.image = [imageCollectionArrays objectAtIndex:indexPath.row];
        }
    
        temp = nil;
        return cell
    }
I need to Drag a image from my table view to my right side image view.can any one provide me a good way to do it
shamsutk87 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 472
13 members and 459 guests
AlanFloyd, AppsBlogger, David-T, HemiMG, iAppDeveloper, imac74, Jaxen66, lovoyl, mutantskin, Paul Slocum, tiendung2992, unicornleo, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,684
Threads: 94,131
Posts: 402,932
Top Poster: BrianSlick (7,990)
Welcome to our newest member, tiendung2992
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:16 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0