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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-23-2009, 09:29 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 6
Dazdh is on a distinguished road
Default Implement a kind of white board on Iphone

Hello,

I'm a beginner on Iphone development (I'm a Java, PHP, C#, C++ programmer).

I would like to implement a kind of "white board" on Facebook, where users can add some photos and draw whatever they want with fingers.

Following some tutorials, I know that it's possible to draw and add photos on any UIView.

However, I'm not quite about two issues:
- first, is it possible to simulate the white board as a map, where users move arount with fingers (exactly like we move around a map with mouse on Google Maps)? Does it mean a sequence of UIView all stuck to each other, and showed one after another on screen following movement done by fingers? Is there a built in stuff to do that? Is it possible to "navigate" inside an UIView bigger than screen?
- second, what about transparency of UIView? In case of users add a photo and then draw on it, does it mean higher view (with drawing) is transperent? Is it possible to do that? Is there any better way to match this goal?

Thanks you very much for your replies.

Best regards,

Dazdh
Dazdh is offline   Reply With Quote
Old 09-23-2009, 09:43 AM   #2 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Dutch will become famous soon enough
Send a message via AIM to Dutch
Default

Have a look at this thread.. It shows how to display a larger image (it is a map in this case) and implement it's sliding around and zooming. There is also a for-loop that adds points to the map that you can ignore, or use to place images on your photos. Once you implemented that, change it so the user can load their own image. Then it is just a matter of the drawing which we can discuss later... This might be a good place to start.
Dutch is offline   Reply With Quote
Old 09-23-2009, 10:18 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 6
Dazdh is on a distinguished road
Default

Hi Dutch, indeed that post is absolutly a very good start. UIImageView on UIScrollView, here it is!! Thanks for your help.

However with this method, only one UIScrollView and one UIImageView are used. Therefore users can only move around one image (the campus map), so it must be fully downloaded once on the begining of the app. My goal is to provide a "huge" white board, where you can move and move again in one direction whitout finding the end. Obvisouly there will be an end at the board, but what I mean is the consecutives pictures that constitute the board (one board, many pictures) should be downloaded only when they are displayed.

Is is a good way to consider only one ScrollView and many ImageView (like the red points on campus map, but replaced in my case by consecutives images forming the board)? In this case, will consecutives images be downloaded only when display? Is there a better way to implement such an issue?

Thanks,

Dazdh
Dazdh is offline   Reply With Quote
Old 09-23-2009, 10:44 AM   #4 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Dutch will become famous soon enough
Send a message via AIM to Dutch
Default

You've got it! All you really need to do is change the map image to display a background image of your choice, and change the generic dots to your photos.

However, instead of using a UIImage, I would use this UIImageView subclass that nobre helped me write. I call it JImage. You essentially initialize it like a UIImage, but you also send it a URL that downloads in its own thread and displays upon download. Oh - an activity indicator is also shown during the download.

Code:
    NSURL *theUrl=[NSURL URLWithString:@"http://www.domain.com/imagename.png"];
    JImage *photoImage=[[JImage alloc] init];
    [photoImage setContentMode:UIViewContentModeScaleAspectFill];
    [photoImage setFrame:CGRectMake(X, Y, W, H)];
    [photoImage initWithImageAtURL:theUrl];	
    [bgImage addSubview:photoImage]
    [photoImage release];
JImage.h
Code:
//
//  JImage.h
//  AlphaEntry
//
//  Created by Jason Goldberg on 9/17/09.
//  All rights reserved.
//

#import <Foundation/Foundation.h>

@interface JImage : UIImageView {

    NSURLConnection *connection;
    NSMutableData* data;
    UIActivityIndicatorView *ai;
}
	
-(void)initWithImageAtURL:(NSURL*)url;	         

@property (nonatomic, retain) NSURLConnection *connection;
@property (nonatomic, retain) NSMutableData* data;
@property (nonatomic, retain) UIActivityIndicatorView *ai;

@end
JImage.m
Code:
//
//  JImage.m
//  AlphaEntry
//
//  Created by Jason Goldberg on 9/17/09.
//  All rights reserved.
//

#import "JImage.h"

@implementation JImage
@synthesize ai,connection, data;

-(void)initWithImageAtURL:(NSURL*)url
{
    [self setContentMode:UIViewContentModeScaleAspectFit];
    if (!ai){
        [self setAi:[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]];	
        [ai startAnimating];
        [ai setFrame:CGRectMake(27, 13, 20, 20)];
        [self addSubview:ai];
    }
	
    NSURLRequest* request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60];
    connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];    

}

- (void)connection:(NSURLConnection *)theConnection	didReceiveData:(NSData *)incrementalData {
    if (data==nil) data = [[NSMutableData alloc] initWithCapacity:2048];
    [data appendData:incrementalData];
}

- (void)connectionDidFinishLoading:(NSURLConnection*)theConnection 
{
    [self setImage:[UIImage imageWithData: data]]; 
    [ai removeFromSuperview];
}

-(void)dealloc{
    [data release];
    [connection release];
    [ai release];
    [super dealloc];
}
@end

Last edited by Dutch; 09-23-2009 at 10:48 AM.
Dutch is offline   Reply With Quote
Old 09-26-2009, 05:35 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 6
Dazdh is on a distinguished road
Default

Very well! Thanks you! I ll test that and I ll get back on this thread.
Dazdh is offline   Reply With Quote
Old 09-29-2009, 03:36 PM   #6 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Dutch will become famous soon enough
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by Dazdh View Post
Very well! Thanks you! I ll test that and I ll get back on this thread.
How did it turn out?
Dutch is offline   Reply With Quote
Old 03-29-2011, 02:15 AM   #7 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 1
mogs is on a distinguished road
Default

Quote:
Originally Posted by Dutch View Post
You've got it! All you really need to do is change the map image to display a background image of your choice, and change the generic dots to your photos.

However, instead of using a UIImage, I would use this UIImageView subclass that nobre helped me write. I call it JImage. You essentially initialize it like a UIImage, but you also send it a URL that downloads in its own thread and displays upon download. Oh - an activity indicator is also shown during the download.

Code:
    NSURL *theUrl=[NSURL URLWithString:@"http://www.domain.com/imagename.png"];
    JImage *photoImage=[[JImage alloc] init];
    [photoImage setContentMode:UIViewContentModeScaleAspectFill];
    [photoImage setFrame:CGRectMake(X, Y, W, H)];
    [photoImage initWithImageAtURL:theUrl];	
    [bgImage addSubview:photoImage]
    [photoImage release];
JImage.h
Code:
//
//  JImage.h
//  AlphaEntry
//
//  Created by Jason Goldberg on 9/17/09.
//  All rights reserved.
//

#import <Foundation/Foundation.h>

@interface JImage : UIImageView {

    NSURLConnection *connection;
    NSMutableData* data;
    UIActivityIndicatorView *ai;
}
	
-(void)initWithImageAtURL:(NSURL*)url;	         

@property (nonatomic, retain) NSURLConnection *connection;
@property (nonatomic, retain) NSMutableData* data;
@property (nonatomic, retain) UIActivityIndicatorView *ai;

@end
JImage.m
Code:
//
//  JImage.m
//  AlphaEntry
//
//  Created by Jason Goldberg on 9/17/09.
//  All rights reserved.
//

#import "JImage.h"

@implementation JImage
@synthesize ai,connection, data;

-(void)initWithImageAtURL:(NSURL*)url
{
    [self setContentMode:UIViewContentModeScaleAspectFit];
    if (!ai){
        [self setAi:[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]];	
        [ai startAnimating];
        [ai setFrame:CGRectMake(27, 13, 20, 20)];
        [self addSubview:ai];
    }
	
    NSURLRequest* request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60];
    connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];    

}

- (void)connection:(NSURLConnection *)theConnection	didReceiveData:(NSData *)incrementalData {
    if (data==nil) data = [[NSMutableData alloc] initWithCapacity:2048];
    [data appendData:incrementalData];
}

- (void)connectionDidFinishLoading:(NSURLConnection*)theConnection 
{
    [self setImage:[UIImage imageWithData: data]]; 
    [ai removeFromSuperview];
}

-(void)dealloc{
    [data release];
    [connection release];
    [ai release];
    [super dealloc];
}
@end


hey it doesn't work... the - (void)connectionNSURLConnection *) theConnection didReceiveDataNSData *)incrementalData and - (void)connectionDidFinishLoadingNSURLConnection* )theConnection
methods are not working.. it does not called ...
mogs is offline   Reply With Quote
Reply

Bookmarks

Tags
map, transparency, uiview

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: 350
10 members and 340 guests
givensur, glenn_sayers, guusleijsten, ipodphone, jbro, mediaspree, mtl_tech_guy, Punkjumper, whitey99, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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