¡@

Home 

2014/10/15 ¤U¤È 10:10:04

iphone Programming Glossary: here's

How to intercept touches events on a MKMapView or UIWebView objects?

http://stackoverflow.com/questions/1049889/how-to-intercept-touches-events-on-a-mkmapview-or-uiwebview-objects

ways turn out to involve a lot of hackish programming that imperfectly duplicates Apple's code. Here's what I do Implement a gesture recognizer that cannot be prevented and that cannot prevent other gesture..

UIImagePickerController and extracting EXIF data from existing photos

http://stackoverflow.com/questions/1238838/uiimagepickercontroller-and-extracting-exif-data-from-existing-photos

and the lack of high level API in the library I don't manage to get the values for the EXIF tags. Here's my code in case any of you can go further #import EXFJpeg.h void imagePickerController UIImagePickerController..

iOS 6 apps - how to deal with iPhone 5 screen size? [duplicate]

http://stackoverflow.com/questions/12396545/ios-6-apps-how-to-deal-with-iphone-5-screen-size

Add UIPickerView & a Button in Action sheet - How?

http://stackoverflow.com/questions/1262574/add-uipickerview-a-button-in-action-sheet-how

a modal view controller containing a simple tableview. There are many ways to accomplish this. Here's one way that I just implemented in a current project. It's nice because I can reuse it between 5 or..

How do I create a basic UIButton programmatically?

http://stackoverflow.com/questions/1378765/how-do-i-create-a-basic-uibutton-programmatically

dynamically and its layout or properties are set. iphone uibutton share improve this question Here's one UIButton button UIButton buttonWithType UIButtonTypeRoundedRect button addTarget self action @selector..

Reading ePub format

http://stackoverflow.com/questions/1388467/reading-epub-format

if you're just starting out parse xml unzip To display content just use a UIWebView for now. Here's a high level step by step for your code 1 create a view with a UIWebView 2 download the EPUB file 3..

How do I detect when someone shakes an iPhone?

http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphone

UIView not UIViewController that you want as firstResponder to receive the shake event messages. Here's the code that you can use in any UIView to get shake events @implementation ShakingView void motionEnded..

Cropping a UIImage

http://stackoverflow.com/questions/158914/cropping-a-uiimage

use to get the desired results CGImageCreateWithImageInRect CGImageRef CGRect will help you out. Here's a short example using it CGImageRef imageRef CGImageCreateWithImageInRect largeImage CGImage cropRect..

Programmatically get own phone number in iOS

http://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-ios

the latest SDK Agreement as of Nov 5 2009. Our application was just rejected for using it. Here's the response from Apple For security reasons iPhone OS restricts an application including its preferences..

Is it true that one should not use NSLog() on production code?

http://stackoverflow.com/questions/300673/is-it-true-that-one-should-not-use-nslog-on-production-code

wrong with NSLog but it's simple to define your own logging function with better functionality. Here's the one I use it includes the file name and line number to make it easier to track down log statements...

Install xCode 3.2.3 w/ iPhone SDK 4, get “Base SDK missing”, can't see other SDKs

http://stackoverflow.com/questions/3161385/install-xcode-3-2-3-w-iphone-sdk-4-get-base-sdk-missing-cant-see-other-sdk

which has a strongly related problem you might want to confer here . One SDK to rule them all Here's the deal 4.0 is now the only SDK version allowed for submitting new or updated iPhone only apps. This..

display image from URL retrieved from ALAsset in iPhone

http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone

the URLs field in the ALAsset object but was unsuccessful. Anybody knows how this can be done Here's some code where I was able to access the thumbnail and place it in a table cell UITableViewCell tableView..

How to customize the background/border colors of a grouped table view cell?

http://stackoverflow.com/questions/400965/how-to-customize-the-background-border-colors-of-a-grouped-table-view-cell

2.0 version of the answer here for anyone that needs it p It's harder than it really should be. Here's how I did this when I had to do it You need to set the UITableViewCell's backgroundView property to.. a real PITA but I've confirmed with Apple engineers that this is currently the only way. Update Here's the code for that custom bg view. There's a drawing bug that makes the rounded corners look a little..

iOS SDK - Programmatically generate a PDF file

http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file

pdfContext We are done with our context now so we release it CGContextRelease pdfContext EDIT Here's an example on GitHub using libHaru in an iPhone project. iphone objective c ipad ios pdf generation.. if you need to create a PDF that works anywhere then you should take a closer look at this issue. Here's some additional info http www.iphonedevsdk.com forum iphone sdk development 15505 pdf font problem cant..

How to send json data in the Http request using NSURLRequest

http://stackoverflow.com/questions/4456966/how-to-send-json-data-in-the-http-request-using-nsurlrequest

you in advance iphone objective c cocoa touch json nsurlrequest share improve this question Here's what I do please note that the JSON going to my server needs to be a dictionary with one value another..

UIImage: Resize, then Crop

http://stackoverflow.com/questions/603907/uiimage-resize-then-crop

the width. I'm working in landscape so might not have noticed any deficiencies in portrait mode. Here's my code it's part of a categeory on UIImage. Target size in my code is always set to the full screen..

performSelector may cause a leak because its selector is unknown

http://stackoverflow.com/questions/7017281/performselector-may-cause-a-leak-because-its-selector-is-unknown

warning by the ARC compiler performSelector may cause a leak because its selector is unknown . Here's what I'm doing _controller performSelector NSSelectorFromString @ someMethod Why do I get this warning.. a reason. It's very rare that this warning should simply be ignored and it's easy to work around. Here's how SEL selector NSSelectorFromString @ someMethod IMP imp _controller methodForSelector selector void..

how to get the message when receiving the “kCTMessageReceivedNotification” notification on IOS5

http://stackoverflow.com/questions/10681995/how-to-get-the-message-when-receiving-the-kctmessagereceivednotification-notif

Here's an example of doing a little more with the database . Look at the QuerySMS method. Also here's a link on the database format of sms.db . You can find what else you need in there. Or just copy the..

Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath:

http://stackoverflow.com/questions/12737860/assertion-failure-in-dequeuereusablecellwithidentifierforindexpath

UITableViewCell alloc initWithStyle UITableViewCellStyleSubtitle reuseIdentifier CellIdentifier here's the error in the output 2012 10 04 20 13 05.356 Reader 4390 c07 Assertion failure in UITableView dequeueReusableCellWithIdentifier.. 0x1c36e1b 0x147da 0x1665c 0x2a02 0x2935 libc abi.dylib terminate called throwing an exception and here's the code it shows in the error screen int main int argc char argv @autoreleasepool return UIApplicationMain..

Verify receipt for in App purchase

http://stackoverflow.com/questions/1298998/verify-receipt-for-in-app-purchase

verifyReceipt with your transaction and make sure it comes back positive. Meanwhile on your server here's some super stripped down PHP to handle things receipt json_encode array receipt data _GET receipt NOTE.. is the length of the payload in the URL going from the app to the server via GET . I forget if there's a length issue there per the RFCs. Maybe it's OK or maybe it's server specific. Readers Advisement welcome..

didFinishPickingMediaWithInfo return nil photo

http://stackoverflow.com/questions/3088874/didfinishpickingmediawithinfo-return-nil-photo

library it worked fine but if the image was a new photo take with the camera it never worked. Well here's how to make it work for both You have to dismiss and release the UIImagePickerController before you..

How to parsing JSON object in iPhone SDK (XCode) using JSON-Framework

http://stackoverflow.com/questions/3165290/how-to-parsing-json-object-in-iphone-sdk-xcode-using-json-framework

question Assuming you've followed the instructions to install JSON Framework into your project here's how you use it taken from the docs here Parse the string into JSON NSDictionary json myString JSONValue..

How do you use NSAttributedString?

http://stackoverflow.com/questions/3482346/how-do-you-use-nsattributedstring

strings I prefer to use the mutable subclass just to keep things cleaner. That being said here's how you create a tri color attributed string NSMutableAttributedString string NSMutableAttributedString..

Build fat static library (device + simulator) using Xcode and SDK 4+

http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4

approach but it doesn't work http www.drobnik.com touch 2010 04 universal static libraries There's some bugs in his script that means it only works on his machine he should be using BUILT_PRODUCTS_DIR.. dont' embed xcode projects too many bugs in Apple's code If you can't find the output file here's a workaround Add the following code to the very end of the script courtesy of Frederik Wallner open..

iOS SDK - Programmatically generate a PDF file

http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file

UIImageView view else if view isKindOfClass UIView class self addContainer view As an example here's my implementation of addImageView HPDF_ functions are from libHaru void addImageView UIImageView imageView..

MKAnnotationView - Lock custom annotation view to pin on location updates

http://stackoverflow.com/questions/6392931/mkannotationview-lock-custom-annotation-view-to-pin-on-location-updates

and the callout annotation will pop back to it's parent. Any ideas Update #1 After playing around here's where I've gotten replaced self.calloutAnnotation.coordinate coords with self.calloutAnnotation.latitude..

Detecting the iPhone's Ring / Silent / Mute switch using AVAudioPlayer not working?

http://stackoverflow.com/questions/6901363/detecting-the-iphones-ring-silent-mute-switch-using-avaudioplayer-not-worki

How do I draw a line on the iPhone?

http://stackoverflow.com/questions/856354/how-do-i-draw-a-line-on-the-iphone

click the dropdown and choose MyView. Next you need to implement the drawRect method in MyView.m here's some example code that draws a line void drawRect CGRect rect CGContextRef c UIGraphicsGetCurrentContext..

How to intercept touches events on a MKMapView or UIWebView objects?

http://stackoverflow.com/questions/1049889/how-to-intercept-touches-events-on-a-mkmapview-or-uiwebview-objects

have found to achieve this is with a Gesture Recognizer. Other ways turn out to involve a lot of hackish programming that imperfectly duplicates Apple's code. Here's what I do Implement a gesture recognizer that cannot be prevented and that cannot prevent other gesture recognizers. Add it to the map view and then use the gestureRecognizer's..

UIImagePickerController and extracting EXIF data from existing photos

http://stackoverflow.com/questions/1238838/uiimagepickercontroller-and-extracting-exif-data-from-existing-photos

because of my limited knwoledge about the EXIF format and the lack of high level API in the library I don't manage to get the values for the EXIF tags. Here's my code in case any of you can go further #import EXFJpeg.h void imagePickerController UIImagePickerController picker didFinishPickingImage UIImage image editingInfo..

iOS 6 apps - how to deal with iPhone 5 screen size? [duplicate]

http://stackoverflow.com/questions/12396545/ios-6-apps-how-to-deal-with-iphone-5-screen-size

Add UIPickerView & a Button in Action sheet - How?

http://stackoverflow.com/questions/1262574/add-uipickerview-a-button-in-action-sheet-how

approach. I replaced the call to show the action sheet with a modal view controller containing a simple tableview. There are many ways to accomplish this. Here's one way that I just implemented in a current project. It's nice because I can reuse it between 5 or 6 different screens where I all users to select from a list..

How do I create a basic UIButton programmatically?

http://stackoverflow.com/questions/1378765/how-do-i-create-a-basic-uibutton-programmatically

the viewDidLoad method three UIButton s will be created dynamically and its layout or properties are set. iphone uibutton share improve this question Here's one UIButton button UIButton buttonWithType UIButtonTypeRoundedRect button addTarget self action @selector aMethod forControlEvents UIControlEventTouchDown button..

Reading ePub format

http://stackoverflow.com/questions/1388467/reading-epub-format

manifest and then to display the relevant content. Some pointers if you're just starting out parse xml unzip To display content just use a UIWebView for now. Here's a high level step by step for your code 1 create a view with a UIWebView 2 download the EPUB file 3 unzip it to a subdirectory in your app's documents folder using..

How do I detect when someone shakes an iPhone?

http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphone

motion events. The main trick is that you need to have some UIView not UIViewController that you want as firstResponder to receive the shake event messages. Here's the code that you can use in any UIView to get shake events @implementation ShakingView void motionEnded UIEventSubtype motion withEvent UIEvent event if event.subtype..

Cropping a UIImage

http://stackoverflow.com/questions/158914/cropping-a-uiimage

class method to do this but there is a function that you can use to get the desired results CGImageCreateWithImageInRect CGImageRef CGRect will help you out. Here's a short example using it CGImageRef imageRef CGImageCreateWithImageInRect largeImage CGImage cropRect or use the UIImage wherever you like UIImageView setImage..

Programmatically get own phone number in iOS

http://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-ios

the highest ranking solution currently the first response violates the latest SDK Agreement as of Nov 5 2009. Our application was just rejected for using it. Here's the response from Apple For security reasons iPhone OS restricts an application including its preferences and data to a unique location in the file system. This..

Is it true that one should not use NSLog() on production code?

http://stackoverflow.com/questions/300673/is-it-true-that-one-should-not-use-nslog-on-production-code

macros are indeed great for debugging. There's nothing wrong with NSLog but it's simple to define your own logging function with better functionality. Here's the one I use it includes the file name and line number to make it easier to track down log statements. #define DEBUG_MODE #ifdef DEBUG_MODE #define DebugLog s..

Install xCode 3.2.3 w/ iPhone SDK 4, get “Base SDK missing”, can't see other SDKs

http://stackoverflow.com/questions/3161385/install-xcode-3-2-3-w-iphone-sdk-4-get-base-sdk-missing-cant-see-other-sdk

If you are specifically interested in the Xcode 3.2.4 upgrade which has a strongly related problem you might want to confer here . One SDK to rule them all Here's the deal 4.0 is now the only SDK version allowed for submitting new or updated iPhone only apps. This is direct from Apple's iOS 4 Readiness Checklist reg reqd..

display image from URL retrieved from ALAsset in iPhone

http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone

view but I am unable to figure out how to do this. I tried using the URLs field in the ALAsset object but was unsuccessful. Anybody knows how this can be done Here's some code where I was able to access the thumbnail and place it in a table cell UITableViewCell tableView UITableView tableView cellForRowAtIndexPath NSIndexPath..

How to customize the background/border colors of a grouped table view cell?

http://stackoverflow.com/questions/400965/how-to-customize-the-background-border-colors-of-a-grouped-table-view-cell

UIColor colorWithPatternImage initializer . But I'll leave the 2.0 version of the answer here for anyone that needs it p It's harder than it really should be. Here's how I did this when I had to do it You need to set the UITableViewCell's backgroundView property to a custom UIView that draws the border and background itself.. the UITableViewDataSource's cellForRowAtIndexPath method. It's a real PITA but I've confirmed with Apple engineers that this is currently the only way. Update Here's the code for that custom bg view. There's a drawing bug that makes the rounded corners look a little funny but we moved to a different design and scrapped the custom..

iOS SDK - Programmatically generate a PDF file

http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file

using CGContextBeginPage CGContextEndPage CGContextEndPage pdfContext We are done with our context now so we release it CGContextRelease pdfContext EDIT Here's an example on GitHub using libHaru in an iPhone project. iphone objective c ipad ios pdf generation share improve this question A couple things... First there.. then you should be fine using CoreGraphics . However if you need to create a PDF that works anywhere then you should take a closer look at this issue. Here's some additional info http www.iphonedevsdk.com forum iphone sdk development 15505 pdf font problem cant get cids glyphs.html#post97854 As a workaround I've used..

How to send json data in the Http request using NSURLRequest

http://stackoverflow.com/questions/4456966/how-to-send-json-data-in-the-http-request-using-nsurlrequest

true options happy true joy true joy2 true key 123 Thank you in advance iphone objective c cocoa touch json nsurlrequest share improve this question Here's what I do please note that the JSON going to my server needs to be a dictionary with one value another dictionary for key question..i.e. question dictionary NSArray..

UIImage: Resize, then Crop

http://stackoverflow.com/questions/603907/uiimage-resize-then-crop

fits once scaled and then crop each end to fit the rest to the width. I'm working in landscape so might not have noticed any deficiencies in portrait mode. Here's my code it's part of a categeory on UIImage. Target size in my code is always set to the full screen size of the device. @implementation UIImage Extras #pragma..

performSelector may cause a leak because its selector is unknown

http://stackoverflow.com/questions/7017281/performselector-may-cause-a-leak-because-its-selector-is-unknown

leak because its selector is unknown I'm getting the following warning by the ARC compiler performSelector may cause a leak because its selector is unknown . Here's what I'm doing _controller performSelector NSSelectorFromString @ someMethod Why do I get this warning I understand the compiler can't check if the selector exists.. question Solution The compiler is warning about this for a reason. It's very rare that this warning should simply be ignored and it's easy to work around. Here's how SEL selector NSSelectorFromString @ someMethod IMP imp _controller methodForSelector selector void func id SEL void imp func _controller selector Or more tersely..

how to get the message when receiving the “kCTMessageReceivedNotification” notification on IOS5

http://stackoverflow.com/questions/10681995/how-to-get-the-message-when-receiving-the-kctmessagereceivednotification-notif

My code snippet just gets the most recent text content. Here's an example of doing a little more with the database . Look at the QuerySMS method. Also here's a link on the database format of sms.db . You can find what else you need in there. Or just copy the sms.db to your computer and browse it with something like the..

Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath:

http://stackoverflow.com/questions/12737860/assertion-failure-in-dequeuereusablecellwithidentifierforindexpath

CellIdentifier forIndexPath indexPath if cell nil cell UITableViewCell alloc initWithStyle UITableViewCellStyleSubtitle reuseIdentifier CellIdentifier here's the error in the output 2012 10 04 20 13 05.356 Reader 4390 c07 Assertion failure in UITableView dequeueReusableCellWithIdentifier forIndexPath SourceCache UIKit_Sim.. 0x1becdf9 0x1becad0 0x1c06bf5 0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x147da 0x1665c 0x2a02 0x2935 libc abi.dylib terminate called throwing an exception and here's the code it shows in the error screen int main int argc char argv @autoreleasepool return UIApplicationMain argc argv nil NSStringFromClass AppDelegate class please..

Verify receipt for in App purchase

http://stackoverflow.com/questions/1298998/verify-receipt-for-in-app-purchase

off recording the transaction on your remote server call verifyReceipt with your transaction and make sure it comes back positive. Meanwhile on your server here's some super stripped down PHP to handle things receipt json_encode array receipt data _GET receipt NOTE use buy vs sandbox in production. url https sandbox.itunes.apple.com.. PHP.net has the scoop One thing that has me slightly concerned is the length of the payload in the URL going from the app to the server via GET . I forget if there's a length issue there per the RFCs. Maybe it's OK or maybe it's server specific. Readers Advisement welcome on this part There may also be some balking at making..

didFinishPickingMediaWithInfo return nil photo

http://stackoverflow.com/questions/3088874/didfinishpickingmediawithinfo-return-nil-photo

if the image was picked from the camera roll photo library it worked fine but if the image was a new photo take with the camera it never worked. Well here's how to make it work for both You have to dismiss and release the UIImagePickerController before you try to do anything with the info dictionary. To be super clear..

How to parsing JSON object in iPhone SDK (XCode) using JSON-Framework

http://stackoverflow.com/questions/3165290/how-to-parsing-json-object-in-iphone-sdk-xcode-using-json-framework

to do that iphone xcode json parsing share improve this question Assuming you've followed the instructions to install JSON Framework into your project here's how you use it taken from the docs here Parse the string into JSON NSDictionary json myString JSONValue Get the objects you want e.g. output the second item's client..

How do you use NSAttributedString?

http://stackoverflow.com/questions/3482346/how-do-you-use-nsattributedstring

share improve this question When building attributed strings I prefer to use the mutable subclass just to keep things cleaner. That being said here's how you create a tri color attributed string NSMutableAttributedString string NSMutableAttributedString alloc initWithString @ firstsecondthird string addAttribute..

Build fat static library (device + simulator) using Xcode and SDK 4+

http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4

that too. References This is a great idea it's an excellent approach but it doesn't work http www.drobnik.com touch 2010 04 universal static libraries There's some bugs in his script that means it only works on his machine he should be using BUILT_PRODUCTS_DIR and or BUILD_DIR instead of guesstimating them Apple's latest.. have Public Headers in your drag dropped project. The workaround dont' embed xcode projects too many bugs in Apple's code If you can't find the output file here's a workaround Add the following code to the very end of the script courtesy of Frederik Wallner open CREATING_UNIVERSAL_DIR Apple deletes all output after 200 lines...

iOS SDK - Programmatically generate a PDF file

http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file

if view isKindOfClass UIImageView class self addImageView UIImageView view else if view isKindOfClass UIView class self addContainer view As an example here's my implementation of addImageView HPDF_ functions are from libHaru void addImageView UIImageView imageView NSData pngData UIImagePNGRepresentation imageView.image..

MKAnnotationView - Lock custom annotation view to pin on location updates

http://stackoverflow.com/questions/6392931/mkannotationview-lock-custom-annotation-view-to-pin-on-location-updates

will have the same effect as doing it manually and the callout annotation will pop back to it's parent. Any ideas Update #1 After playing around here's where I've gotten replaced self.calloutAnnotation.coordinate coords with self.calloutAnnotation.latitude coords.latitude self.calloutAnnotation.longitude coords.longitude..

Detecting the iPhone's Ring / Silent / Mute switch using AVAudioPlayer not working?

http://stackoverflow.com/questions/6901363/detecting-the-iphones-ring-silent-mute-switch-using-avaudioplayer-not-worki

How do I draw a line on the iPhone?

http://stackoverflow.com/questions/856354/how-do-i-draw-a-line-on-the-iphone

4 to bring up the Identity Inspector and under Class Identity click the dropdown and choose MyView. Next you need to implement the drawRect method in MyView.m here's some example code that draws a line void drawRect CGRect rect CGContextRef c UIGraphicsGetCurrentContext CGFloat red 4 1.0f 0.0f 0.0f 1.0f CGContextSetStrokeColor..

How to intercept touches events on a MKMapView or UIWebView objects?

http://stackoverflow.com/questions/1049889/how-to-intercept-touches-events-on-a-mkmapview-or-uiwebview-objects

Recognizer. Other ways turn out to involve a lot of hackish programming that imperfectly duplicates Apple's code. Here's what I do Implement a gesture recognizer that cannot be prevented and that cannot prevent other gesture recognizers. Add..

UIImagePickerController and extracting EXIF data from existing photos

http://stackoverflow.com/questions/1238838/uiimagepickercontroller-and-extracting-exif-data-from-existing-photos

the EXIF format and the lack of high level API in the library I don't manage to get the values for the EXIF tags. Here's my code in case any of you can go further #import EXFJpeg.h void imagePickerController UIImagePickerController picker didFinishPickingImage..

iOS 6 apps - how to deal with iPhone 5 screen size? [duplicate]

http://stackoverflow.com/questions/12396545/ios-6-apps-how-to-deal-with-iphone-5-screen-size

Add UIPickerView & a Button in Action sheet - How?

http://stackoverflow.com/questions/1262574/add-uipickerview-a-button-in-action-sheet-how

the action sheet with a modal view controller containing a simple tableview. There are many ways to accomplish this. Here's one way that I just implemented in a current project. It's nice because I can reuse it between 5 or 6 different screens..

How do I create a basic UIButton programmatically?

http://stackoverflow.com/questions/1378765/how-do-i-create-a-basic-uibutton-programmatically

s will be created dynamically and its layout or properties are set. iphone uibutton share improve this question Here's one UIButton button UIButton buttonWithType UIButtonTypeRoundedRect button addTarget self action @selector aMethod forControlEvents..

Reading ePub format

http://stackoverflow.com/questions/1388467/reading-epub-format

content. Some pointers if you're just starting out parse xml unzip To display content just use a UIWebView for now. Here's a high level step by step for your code 1 create a view with a UIWebView 2 download the EPUB file 3 unzip it to a subdirectory..

How do I detect when someone shakes an iPhone?

http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphone

you need to have some UIView not UIViewController that you want as firstResponder to receive the shake event messages. Here's the code that you can use in any UIView to get shake events @implementation ShakingView void motionEnded UIEventSubtype..

Cropping a UIImage

http://stackoverflow.com/questions/158914/cropping-a-uiimage

function that you can use to get the desired results CGImageCreateWithImageInRect CGImageRef CGRect will help you out. Here's a short example using it CGImageRef imageRef CGImageCreateWithImageInRect largeImage CGImage cropRect or use the UIImage..

Programmatically get own phone number in iOS

http://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-ios

the first response violates the latest SDK Agreement as of Nov 5 2009. Our application was just rejected for using it. Here's the response from Apple For security reasons iPhone OS restricts an application including its preferences and data to a..

Is it true that one should not use NSLog() on production code?

http://stackoverflow.com/questions/300673/is-it-true-that-one-should-not-use-nslog-on-production-code

There's nothing wrong with NSLog but it's simple to define your own logging function with better functionality. Here's the one I use it includes the file name and line number to make it easier to track down log statements. #define DEBUG_MODE..

Install xCode 3.2.3 w/ iPhone SDK 4, get “Base SDK missing”, can't see other SDKs

http://stackoverflow.com/questions/3161385/install-xcode-3-2-3-w-iphone-sdk-4-get-base-sdk-missing-cant-see-other-sdk

the Xcode 3.2.4 upgrade which has a strongly related problem you might want to confer here . One SDK to rule them all Here's the deal 4.0 is now the only SDK version allowed for submitting new or updated iPhone only apps. This is direct from Apple's..

display image from URL retrieved from ALAsset in iPhone

http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone

do this. I tried using the URLs field in the ALAsset object but was unsuccessful. Anybody knows how this can be done Here's some code where I was able to access the thumbnail and place it in a table cell UITableViewCell tableView UITableView tableView..

How to customize the background/border colors of a grouped table view cell?

http://stackoverflow.com/questions/400965/how-to-customize-the-background-border-colors-of-a-grouped-table-view-cell

. But I'll leave the 2.0 version of the answer here for anyone that needs it p It's harder than it really should be. Here's how I did this when I had to do it You need to set the UITableViewCell's backgroundView property to a custom UIView that.. method. It's a real PITA but I've confirmed with Apple engineers that this is currently the only way. Update Here's the code for that custom bg view. There's a drawing bug that makes the rounded corners look a little funny but we moved..

iOS SDK - Programmatically generate a PDF file

http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file

CGContextEndPage pdfContext We are done with our context now so we release it CGContextRelease pdfContext EDIT Here's an example on GitHub using libHaru in an iPhone project. iphone objective c ipad ios pdf generation share improve this.. . However if you need to create a PDF that works anywhere then you should take a closer look at this issue. Here's some additional info http www.iphonedevsdk.com forum iphone sdk development 15505 pdf font problem cant get cids glyphs.html#post97854..

How to send json data in the Http request using NSURLRequest

http://stackoverflow.com/questions/4456966/how-to-send-json-data-in-the-http-request-using-nsurlrequest

true key 123 Thank you in advance iphone objective c cocoa touch json nsurlrequest share improve this question Here's what I do please note that the JSON going to my server needs to be a dictionary with one value another dictionary for key..

UIImage: Resize, then Crop

http://stackoverflow.com/questions/603907/uiimage-resize-then-crop

to fit the rest to the width. I'm working in landscape so might not have noticed any deficiencies in portrait mode. Here's my code it's part of a categeory on UIImage. Target size in my code is always set to the full screen size of the device...

performSelector may cause a leak because its selector is unknown

http://stackoverflow.com/questions/7017281/performselector-may-cause-a-leak-because-its-selector-is-unknown

getting the following warning by the ARC compiler performSelector may cause a leak because its selector is unknown . Here's what I'm doing _controller performSelector NSSelectorFromString @ someMethod Why do I get this warning I understand the.. about this for a reason. It's very rare that this warning should simply be ignored and it's easy to work around. Here's how SEL selector NSSelectorFromString @ someMethod IMP imp _controller methodForSelector selector void func id SEL void..

iOS PNG Image rotated 90 degrees

http://stackoverflow.com/questions/10307521/ios-png-image-rotated-90-degrees

JPEGs I wouldn't have this problem it sounds due to the EXIF information. My app has full copy paste functionality and here's the kicker I'll write this in steps so it is easier to follow Go to my camera roll and copy an image Go into my app and..

iOS Image Orientation has Strange Behavior

http://stackoverflow.com/questions/10600613/ios-image-orientation-has-strange-behavior

looks like when opened with Windows Photo Viewer still not handled properly After all of the comments on this question here's what I'm thinking... The iPhone takes an image and says to display this properly it needs to be rotated 90 degrees . This..

how to get the message when receiving the “kCTMessageReceivedNotification” notification on IOS5

http://stackoverflow.com/questions/10681995/how-to-get-the-message-when-receiving-the-kctmessagereceivednotification-notif

recent text content. Here's an example of doing a little more with the database . Look at the QuerySMS method. Also here's a link on the database format of sms.db . You can find what else you need in there. Or just copy the sms.db to your computer..

Optimizing CLLocationManager/CoreLocation to retrieve data points faster on the iPhone

http://stackoverflow.com/questions/1081219/optimizing-cllocationmanager-corelocation-to-retrieve-data-points-faster-on-the

example Tweetero http tweetero.googlecode.com svn trunk I'm thinking you can only have one location manager running there's only one GPS chip in the iPhone thus if you launch multiple location manager object's they'll conflict and you get errors.. self.delegate newLocationUpdate currentLocation If you have a iPhone 3GS getting Heading updates is a lot easier here's the code in the same module as above This is the Heading or Compass values void locationManager CLLocationManager manager..

Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath:

http://stackoverflow.com/questions/12737860/assertion-failure-in-dequeuereusablecellwithidentifierforindexpath

if cell nil cell UITableViewCell alloc initWithStyle UITableViewCellStyleSubtitle reuseIdentifier CellIdentifier here's the error in the output 2012 10 04 20 13 05.356 Reader 4390 c07 Assertion failure in UITableView dequeueReusableCellWithIdentifier.. 0x1c37bb6 0x1c36f44 0x1c36e1b 0x147da 0x1665c 0x2a02 0x2935 libc abi.dylib terminate called throwing an exception and here's the code it shows in the error screen int main int argc char argv @autoreleasepool return UIApplicationMain argc argv nil..

Verify receipt for in App purchase

http://stackoverflow.com/questions/1298998/verify-receipt-for-in-app-purchase

remote server call verifyReceipt with your transaction and make sure it comes back positive. Meanwhile on your server here's some super stripped down PHP to handle things receipt json_encode array receipt data _GET receipt NOTE use buy vs sandbox.. me slightly concerned is the length of the payload in the URL going from the app to the server via GET . I forget if there's a length issue there per the RFCs. Maybe it's OK or maybe it's server specific. Readers Advisement welcome on this part..

Break on EXC_BAD_ACCESS in XCode?

http://stackoverflow.com/questions/1622079/break-on-exc-bad-access-in-xcode

that an NSMutableArray I have a property for on my class was a zombie. I went into the init function for the class and here's the code I was using if self super init NSMutableArray array NSMutableArray array self.terrainBlocks array array release..

How to convert an NSString to hex values

http://stackoverflow.com/questions/3056757/how-to-convert-an-nsstring-to-hex-values

s null return null return new String Hex.decodeHex s.toCharArray ENCODING_UTF8 Update Thanks to drawnonward's answer here's the method I wrote to create the hex NSStrings. It gives me an Initialization discards qualifiers from pointer target type..

didFinishPickingMediaWithInfo return nil photo

http://stackoverflow.com/questions/3088874/didfinishpickingmediawithinfo-return-nil-photo

camera roll photo library it worked fine but if the image was a new photo take with the camera it never worked. Well here's how to make it work for both You have to dismiss and release the UIImagePickerController before you try to do anything with..

How to parsing JSON object in iPhone SDK (XCode) using JSON-Framework

http://stackoverflow.com/questions/3165290/how-to-parsing-json-object-in-iphone-sdk-xcode-using-json-framework

share improve this question Assuming you've followed the instructions to install JSON Framework into your project here's how you use it taken from the docs here Parse the string into JSON NSDictionary json myString JSONValue Get the objects..

How do you use NSAttributedString?

http://stackoverflow.com/questions/3482346/how-do-you-use-nsattributedstring

When building attributed strings I prefer to use the mutable subclass just to keep things cleaner. That being said here's how you create a tri color attributed string NSMutableAttributedString string NSMutableAttributedString alloc initWithString..

Build fat static library (device + simulator) using Xcode and SDK 4+

http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4

idea it's an excellent approach but it doesn't work http www.drobnik.com touch 2010 04 universal static libraries There's some bugs in his script that means it only works on his machine he should be using BUILT_PRODUCTS_DIR and or BUILD_DIR instead.. project. The workaround dont' embed xcode projects too many bugs in Apple's code If you can't find the output file here's a workaround Add the following code to the very end of the script courtesy of Frederik Wallner open CREATING_UNIVERSAL_DIR..

Fixed labels in the selection bar of a UIPickerView

http://stackoverflow.com/questions/367471/fixed-labels-in-the-selection-bar-of-a-uipickerview

Answer I followed Ed Marty's advice answer below and it works Not perfect but it should fool people. For reference here's my implementation feel free to make it better... void viewDidLoad Add pickerView self.pickerView UIPickerView alloc initWithFrame..

iOS SDK - Programmatically generate a PDF file

http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file

self addImageView UIImageView view else if view isKindOfClass UIView class self addContainer view As an example here's my implementation of addImageView HPDF_ functions are from libHaru void addImageView UIImageView imageView NSData pngData..

Uploading live streaming video from iPhone [duplicate]

http://stackoverflow.com/questions/5062266/uploading-live-streaming-video-from-iphone

streaming video from iPhone duplicate How to live stream videos from iPhone to server like Ustream or Qik I know there's something called Http Live Streaming from Apple but most resources I found only talks about streaming videos from server.. AudioVideo Conceptual AVFoundationPG Articles 03_MediaCapture.html# apple_ref doc uid TP40010188 CH5 SW2 And here's some code make input device NSError deviceError AVCaptureDevice cameraDevice AVCaptureDevice defaultDeviceWithMediaType..

MKAnnotationView - Lock custom annotation view to pin on location updates

http://stackoverflow.com/questions/6392931/mkannotationview-lock-custom-annotation-view-to-pin-on-location-updates

as doing it manually and the callout annotation will pop back to it's parent. Any ideas Update #1 After playing around here's where I've gotten replaced self.calloutAnnotation.coordinate coords with self.calloutAnnotation.latitude coords.latitude..

Calculate new coordinate x meters and y degree away from one coordinate

http://stackoverflow.com/questions/6633850/calculate-new-coordinate-x-meters-and-y-degree-away-from-one-coordinate

double degrees Thanks iphone objective c geolocation location mapkit share improve this question Unfortunately there's no such function provided in the api so you'll have to write your own. This site gives several calculations involving latitude.. from start point shows how to calculate what you're asking. The JavaScript code is at the bottom of that page and here's one possible way to convert it to Objective C double radiansFromDegrees double degrees return degrees M_PI 180.0 double..

Detecting the iPhone's Ring / Silent / Mute switch using AVAudioPlayer not working?

http://stackoverflow.com/questions/6901363/detecting-the-iphones-ring-silent-mute-switch-using-avaudioplayer-not-worki

How do I draw a line on the iPhone?

http://stackoverflow.com/questions/856354/how-do-i-draw-a-line-on-the-iphone

under Class Identity click the dropdown and choose MyView. Next you need to implement the drawRect method in MyView.m here's some example code that draws a line void drawRect CGRect rect CGContextRef c UIGraphicsGetCurrentContext CGFloat red 4 1.0f..