two app versions

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,288
0
Stillwater, OK
hello,

I'm wondering how can I make iPod only version of my app as there is some features that require a camera and if i use that app on the iPod it will crash, what should I do? should I create two independent apps or is there a code to check the device and strip out the code? any documentation links?

thanks
 

robbieduncan

Moderator emeritus
Jul 24, 2002
24,488
11
London
You should check at runtime if the camera is available and write your code correctly so as it does not crash if it's not.
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,288
0
Stillwater, OK
Ok I feel really noob right now :eek: I have disabled the action now but how can I remove the button it self from the view.

Thanks
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,288
0
Stillwater, OK
Code:
[button removeFromSuperView];

I tired it now, but it removes the button after i selected the 1st one and chose the image from library, here is my code:

Code:
#import "testPickerViewController.h"

@implementation testPickerViewController

@synthesize imgPicker;
@synthesize imgPickerCam;
@synthesize spinner;





- (IBAction)grabImage {
	if ( (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]))

		
	{				
		
		
		if(imgPicker == nil){
	self.imgPicker = [[UIImagePickerController alloc] init];
	self.imgPicker.delegate = self;	
	self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
	[self presentModalViewController:self.imgPicker animated:YES];
			[button removeFromSuperview];
		}
	

}

}
		-(IBAction)grabImageCam {
			
			
			
			
					
	self.imgPickerCam = [[UIImagePickerController alloc] init];
	self.imgPickerCam.delegate = self;
	self.imgPickerCam.sourceType = UIImagePickerControllerSourceTypeCamera;
	[self presentModalViewController:self.imgPickerCam animated:YES];
				
}






  - (IBAction)uploadImage {
	  [spinner startAnimating];
	/*
	 turning the image into a NSData object
	 getting the image back out of the UIImageView
	 setting the quality to 90
	 */
	  
	  [spinner stopAnimating];
	  
	NSData *imageData = UIImageJPEGRepresentation(image.image, 100);
	  

	// setting up the URL to post to
	NSString *urlString = @"http://mozymac.com/upload.php";
	
	// setting up the request object now
	NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
	[request setURL:[NSURL URLWithString:urlString]];
	[request setHTTPMethod:@"POST"];
	
	/*
	 add some header info now
	 we always need a boundary when we post a file
	 also we need to set the content type
	 
	 You might want to generate a random boundary.. this is just the same 
	 as my output from wireshark on a valid html post
	 */
	NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
	NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
	[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
	
	/*
	 now lets create the body of the post
	 */
	NSMutableData *body = [NSMutableData data];
	[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];	
	[body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"userfile\"; filename=\".jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[NSData dataWithData:imageData]];
	[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
	// setting the body of the post to the reqeust
	[request setHTTPBody:body];
	
	// now lets make the connection to the web
	NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
	NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
	  
	
	myTextField.text = (returnString);
	
	 
	
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
	image.image = img;	

	[[picker parentViewController] dismissModalViewControllerAnimated:YES];
	[spinner startAnimating];
	// need to show the upload image button now
	upload.hidden = NO;
}
@end
 

dejo

Moderator
Staff member
Sep 2, 2004
15,725
447
The Centennial State
I tired moving it around but all places didn't work, that's why I posted my code hoping you could help me find the correct place :D
Is removing the button, in and of itself, not working? If this is the case, where have you set the value of button?

If the button is being removed okay but just not at the right time, sit back and think about where, as the code executes, views are set up, etc., you want the button to not appear. That should help identify where you need to put the call.
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,288
0
Stillwater, OK
Is removing the button, in and of itself, not working? If this is the case, where have you set the value of button?

If the button is being removed okay but just not at the right time, sit back and think about where, as the code executes, views are set up, etc., you want the button to not appear. That should help identify where you need to put the call.
it's seniro number two, after the application is loaded the two buttons appear, when I select the library one then select a photo, the 2nd one is then gone.
 

dejo

Moderator
Staff member
Sep 2, 2004
15,725
447
The Centennial State
it's seniro number two, after the application is loaded the two buttons appear, when I select the library one then select a photo, the 2nd one is then gone.
And when do you actually want the button to no longer appear? After the application (view) is loaded?
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,288
0
Stillwater, OK
If only there was an instance method that let you know when a view Did Load... ;)

:D thanks it works now, I don't know how i forgot about that LOL. Thanks again.

by the way, someone told me it's not allowed to have 2 looks for my apps i.e (one for iphone and ipod) and that apple would probably reject my app if I did so, what are thoughts about this.

Thanks :D
 

robbieduncan

Moderator emeritus
Jul 24, 2002
24,488
11
London
:D thanks it works now, I don't know how i forgot about that LOL. Thanks again.

by the way, someone told me it's not allowed to have 2 looks for my apps i.e (one for iphone and ipod) and that apple would probably reject my app if I did so, what are thoughts about this.

Thanks :D
There must be other apps out there that present different interfaces based on camera availability. Probably hundreds of them...
 

dejo

Moderator
Staff member
Sep 2, 2004
15,725
447
The Centennial State
:D thanks it works now, I don't know how i forgot about that LOL. Thanks again.
You're welcome. Don't forget to rely on the documentation, especially the Class References. They're there to help you.

by the way, someone told me it's not allowed to have 2 looks for my apps i.e (one for iphone and ipod) and that apple would probably reject my app if I did so, what are thoughts about this
Actually, for what you are doing, Apple would reject it if you left the button when running on an iPod touch. They don't like you to leave UI elements for things that are unsupported. For [app]CraigsHarvest Lite[/app], we had to remove a button that only worked in the full version. We couldn't use it as an opportunity to remind the user of the availability of the full version.
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,288
0
Stillwater, OK
Actually, for what you are doing, Apple would reject it if you left the button when running on an iPod touch. They don't like you to leave UI elements for things that are unsupported. For [app]CraigsHarvest Lite[/app], we had to remove a button that only worked in the full version. We couldn't use it as an opportunity to remind the user of the availability of the full version.
so what should I do, should I make to separate apps?