UIPickerview regulátor není schopen vybrat obraz a použití v xcode4.2 ale funguje dobře na Xcode 3.2

hlasů
1

Mám UIImagePickerController tento kód dále běží dobře na Xcode 3.2, ale aplikace visí wen dodrženy z Xcode 4.2

Také ale někdy to běží na jiných strojích jednou.

Může mi někdo říct, d důvod ze tohle? Díky moc.

    -(IBAction)showActionSheet:(id)sender {
    UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@Add Photo delegate:self cancelButtonTitle:@Cancel destructiveButtonTitle:@Take Photo otherButtonTitles:@Choose From Library, nil];
    popupQuery.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    [popupQuery showInView:self.view];
    [popupQuery release];
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {

        [self addLoaderWithtext:@Please wait...];
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
//        [self.mtextView resignFirstResponder];
//        [self.mtextView2 resignFirstResponder];
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentModalViewController:picker animated:YES];
        [picker release];



    } else if (buttonIndex == 1) {

        [self addLoaderWithtext:@Please wait...];
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        [self presentModalViewController:picker animated:YES];
        [picker release];

    } 



}



- (IBAction)pushUpload {


    [self removeLoader];
    [self addLoaderWithtext:@Uploading Image...];


    double compressionRatio=0;

    UIImage *inputImage = [UIImage imageWithCGImage:[imageView.image CGImage] scale:1.0 orientation:UIImageOrientationRight];
    //imageView.image = [[UIImage imageView.image]_imageScaledToSize:CGSizeMake(32.0f, 32.0f) interpolationQuality:1];
    NSData *imageData=UIImageJPEGRepresentation(inputImage,compressionRatio);
    NSString *urlString = @XXXXXXXXXXXXXXXXXXXXXXXXX;
    //while ([imageData length]>1) { 
//        compressionRatio=compressionRatio*0.5;
//        imageData=UIImageJPEGRepresentation(imageView.image,compressionRatio);
//  }
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
    [request setURL:[NSURL URLWithString:urlString]];
    [request setHTTPMethod:@POST];

    NSString *boundary = [NSString stringWithString:@---------------------------14737809831466499882746641449];
    NSString *contentType = [NSString stringWithFormat:@multipart/form-data; boundary=%@, boundary];
    [request addValue:contentType forHTTPHeaderField:@Content-Type];

    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]];
    [request setHTTPBody:body];

    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
    imageurl = returnString;
    NSLog(@returnString:%@,returnString);

    [NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(onTick1:) userInfo:nil repeats:YES];



}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)info {


[NSTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(onTick1:) userInfo:nil repeats:YES];
double compressionRatio=1;
imageView.image=UIImageJPEGRepresentation([info objectForKey:@UIImagePickerControllerOriginalImage],compressionRatio);
while ([imageView.image length]>1) { 
    compressionRatio=compressionRatio*0.1;
    imageView.image=UIImageJPEGRepresentation([info objectForKey:@UIImagePickerControllerOriginalImage],compressionRatio);


}




imageView.image = image;

[self   pushUpload];
[picker.parentViewController dismissModalViewControllerAnimated:YES];

}

  • (Neplatné) imagePickerControllerDidCancel: (UIImagePickerController *) sběrač {[picker.parentViewController dismissModalViewControllerAnimated: ANO]; }
Položena 02/11/2011 v 14:57
zdroj uživatelem
V jiných jazycích...                            

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more