iphone-sdk-3.0

NSHTTPURLResponse statusCode is returning zero when it should be 401 [duplicate]

若如初见. 提交于 2019-12-04 13:20:27
Possible Duplicate: iOS: How can i receive HTTP 401 instead of -1012 NSURLErrorUserCancelledAuthentication Just doing a normal HTTP post with a NSMutableURLRequest and sendSynchronousRequest. But the NSHTTPURLResponse object I pass in has a statusCode of zero after the call. I get this error: Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0x4d3b3c0 "Operation could not be completed. (NSURLErrorDomain error -1012.)" but no status code. Why? The status code the server is sending is 401. I don't have a solution to the problem, but here is a list of NSURLErrorDomain codes of which -1012 refers

How to find out if the iPhone is on silent mode?

放肆的年华 提交于 2019-12-04 13:07:35
I have a mailing application. If the user sends a mail successfully, then I need to notify that the mail was sent successfully. For that, I need to know if his phone is on silent mode (in which case there will be a 'vibrate') or regular mode (in which case there will be a 'beep'). Can anyone help me with it? Thanks in advance CFStringRef state; UInt32 propertySize = sizeof(CFStringRef); AudioSessionInitialize(NULL, NULL, NULL, NULL); AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state); if(CFStringGetLength(state) == 0) { //SILENT } else { //NOT SILENT } If the

How do I change the UITextField so it looks like the Search Text Field?

空扰寡人 提交于 2019-12-04 12:47:20
I would like to change the standard iPhone UITextField so that it looks exactly like the search text field within the UISearchBar. You can see an example of this for the SMS text entry field within the iPhone Messages application. I do not believe that the UITextField has a style property that will meet this requirement. Any ideas? If you want, you can actually extract the background image from a uisearch bar and make it a stretchable image to use as the background of a UITextField. I did the same thing and it works like a charm for me. Here's the code i used to extract it: UIImage *img = [[

Image processing on the iPhone

天大地大妈咪最大 提交于 2019-12-04 12:46:06
I would like to apply image processing on pictures taken on the iPhone. This processing would involve 2D matrix convolutions etc. I'm afraid that the performance with nested NSArrays would be pretty bad. What is the right way to manipulate pixel based images? Should I simply use C arrays allocated with malloc ? Have you looked at the Quartz 2D engine available in the iPhone SDK? Or perhaps Core Graphics? Apple has a nice overview document describing all the different imaging technologies available on the iPhone. Unfortunately there isn't anything as nice as ImageKit on the iPhone yet. I

iPhone vertical toggle switch

早过忘川 提交于 2019-12-04 12:20:38
I'm trying to create a vertical toggle switch control for the iPhone (along the lines of UISwitch but vertical sliding). I was wondering whether an existing control already existed or if there are any good tutorials that explain the basics of creating custom controls for the iPhone. Currently I've tried using affine transforms to create the vertical switch from a basic UIswitch, and it works except that the slider is too small compared to the slider track, thus I'm looking for information on writing custom controls. Any direction is much appreciated. You could use a UIButton and two images to

How to implement a LowPass Filter?

↘锁芯ラ 提交于 2019-12-04 12:15:39
问题 I'm doing some math on both gyroscope and accelerometer data combined and I'd like to low pass filter the resulting data. So could someone post some generic code for a Low Pass filter? 回答1: A 1st order IIR low-pass filter can be of the form: output_value = rate * input_value + (1.0 - rate) * previous_output_value; which is pretty much what's inside Apple's AccelerometerGraph example. You select the rate parameter depending on what frequency (very very roughly shakes per second) you want to

UIApplication openUrl not working with formatted NSString

孤人 提交于 2019-12-04 10:08:07
问题 I have the following code to open google maps: NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@, Anchorage, AK",addressString]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; But it doesn't work and there is no error. It just doesn't open. 回答1: URLWithString requires a percent-escaped string. Your sample url contains spaces which results in a nil NSURL being created. Additionally, the addressString may also contain characters

UITextView touch events not firing

佐手、 提交于 2019-12-04 09:45:53
I have a UITextView that I want to detect a single tap for. It looks like I would be fine with simply overriding touchesEnded:withEvent and checking [[touches anyObject] tapCount] == 1 , however this event doesn't even fire. If I override the 4 events like this: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; NSLog(@"touchesBegan (tapCount:%d)", touch.tapCount); [super touchesBegan:touches withEvent:event]; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touches moved"); } -(void)touchesEnded:(NSSet *)touches

How to write/get latitude longitude with image in uiimagepickercontroller?

ぃ、小莉子 提交于 2019-12-04 08:34:12
Currently I am saving and image with the following method in "saved photos album". UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); Now I want to associate the current latitude and longitude with that image. How can I do so ? Can I do with its mediaInfo dictionary (metadata). I am working in ios sdk 3.0 . Please tell me How to get /set geo data with an image in UIImageViewPickerController AFAIK this is not supported in iOS 4.0 and lower. As of iOS 4.1, you can use -[ALAssetsLibrary writeImageToSavedPhotosAlbum:metadata:completionBlock:]

What is the difference between a regular and adaptive low pass filter?

对着背影说爱祢 提交于 2019-12-04 07:26:23
I've noticed in Apple's accelerometer sample code they use both regular and adaptive low pass filters, what is the difference? They are both IIR 1st order low pass filters (simple, and laggy in responsiveness when compared with other DSP techniques). The adaptive filter switches to a higher frequency roll-off (and thus becomes even less smoothing but more responsive) for larger accelerations. There are other higher quality (and more complicated) DSP filtering techniques for motion sensing often used by portable game developers. In general, any adaptive filter will adjust itself based on the