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 02-04-2010, 09:25 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Germany
Posts: 21
kuba1234 is on a distinguished road
Default how to get IBAction from 2view in 1view

Hi, i'm playing with two views and try to change one image in die second view, which is visible in first view. I found many tutorials with passing data between views, for example typing text in label (second view) and display it in a label in first view.
in my first view:
Code:
- (void)updateLabel
{
	NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	userInfoLabel.text = [defaults objectForKey:@"userInfoKey"];
}
and in second (IBAction):
Code:
	NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	NSString *string = [[NSString alloc] initWithFormat:@"%@ %@\n%@", firstNameField.text, lastNameField.text, addressField.text];
	[defaults setObject:string forKey:@"userInfoKey"];
	[defaults synchronize];
	[self dismissModalViewControllerAnimated:YES];
How can I change this code to get it working with images??
__________________
MyApps: Kalimba,Ducky,Pocket Bell,Pistol
kuba1234 is offline   Reply With Quote
Old 02-04-2010, 09:33 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Well, the bad part is you're never going to learn anything by doing this. Copy & Paste code for one purpose, then ask other people to help you adapt it for another purpose.

Regardless, you're thinking of the solution incorrectly. Dont pass the actual image from view to view. Instead, write the image name to NSUSerDefaults, just like the code you already have. Then in your other view, read the name of the image, and then create a new UIImage from that.

FYI, there are much better ways for passing data back and forth between views than using NSUserDefaults.
smithdale87 is offline   Reply With Quote
Old 02-05-2010, 07:40 AM   #3 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Germany
Posts: 21
kuba1234 is on a distinguished road
Default

Quote:
Well, the bad part is you're never going to learn anything by doing this. Copy & Paste code for one purpose, then ask other people to help you adapt it for another purpose.
Sorry, it was not my intention. I spend many hours to adapt it for my app, without working results.

My next try (in first view):
Code:
- (void)updateImage{
	NSUserDefaults *defaultImage = [NSUserDefaults standardUserDefaults];
	imageView2.image = [defaultImage objectForKey:@"userInfoImageKey"];
and in secondView:
Code:
NSUserDefaults *defaultImage = [NSUserDefaults standardUserDefaults];
	NSString *stringImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"feuer.png" ,stringImage]]];
	[defaultImage setObject:stringImage forKey:@"userInfoImageKey"];
	[defaultImage synchronize];
Is this, what you mean? But it does't work.
Please help me!

Quote:
there are much better ways for passing data back and forth between views than using NSUserDefaults.
pleas give me a note for something about this.
__________________
MyApps: Kalimba,Ducky,Pocket Bell,Pistol
kuba1234 is offline   Reply With Quote
Old 09-20-2010, 04:48 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Germany
Posts: 21
kuba1234 is on a distinguished road
Default

have someone any sample code for me???
Please help.
__________________
MyApps: Kalimba,Ducky,Pocket Bell,Pistol
kuba1234 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: 321
6 members and 315 guests
2Apps1Day, akacaj, SLIC, soohyun, Techgirl-52, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,115
Posts: 402,887
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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