¡@

Home 

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

iphone Programming Glossary: trick

How to make a UITextField move up when keyboard is present

http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present

one go inside the other EDIT I now know that you want a UIView inside of a UIScrollView and the trick is to programatically set the content size of the UIScrollView to the frame size of the UIView . Then..

UIScrollView horizontal paging like Mobile Safari tabs

http://stackoverflow.com/questions/1220354/uiscrollview-horizontal-paging-like-mobile-safari-tabs

Then since you want to see the other pages of course set clipsToBounds to NO as mhjoy stated. The trick part now is getting it to scroll when the user starts the drag outside the range of the UIScrollView..

Getting thumbnail from a video url or data in IPhone SDK

http://stackoverflow.com/questions/1347562/getting-thumbnail-from-a-video-url-or-data-in-iphone-sdk

using AVFoundation the following code where the class property url is the movie url will do the trick you can get the thumbnail at any time in the example its at time 0 void generateImage AVURLAsset asset..

How do I detect when someone shakes an iPhone?

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

improve this question In 3.0 there's now an easier way hook into the new motion events. The main trick is that you need to have some UIView not UIViewController that you want as firstResponder to receive..

Is there a documented way to set the iPhone orientation?

http://stackoverflow.com/questions/181780/is-there-a-documented-way-to-set-the-iphone-orientation

rotation to be set to portrait. There is an undocumented property setter on UIDevice that does the trick but obviously generates a compiler warning and could disappear with a future revision of the SDK. UIDevice..

Creating a left-arrow button (like UINavigationBar's “back” style) on a UIToolbar

http://stackoverflow.com/questions/227078/creating-a-left-arrow-button-like-uinavigationbars-back-style-on-a-uitoolba

Edit As pointed out by PrairieHippo maralbjo found that using the following simple code did the trick requires custom image in bundle should be combined with this answer. So here is additional code Creates..

How to intercept click on link in UITextView?

http://stackoverflow.com/questions/2543967/how-to-intercept-click-on-link-in-uitextview

Objective-C categories in static library

http://stackoverflow.com/questions/2567498/objective-c-categories-in-static-library

h m files empty dummy class interface implementation to force linker use this file. And yes this trick do the job. But author also said he even not instantiated dummy object. Mm As I've found we should explicitly..

underline text in UIlabel

http://stackoverflow.com/questions/2711297/underline-text-in-uilabel

Popover with embedded navigation controller doesn't respect size on back nav

http://stackoverflow.com/questions/2752394/popover-with-embedded-navigation-controller-doesnt-respect-size-on-back-nav

easily create category on UIViewController with the following helper method that would do the trick with setting the size void forcePopoverSize CGSize currentSetSizeForPopover self.contentSizeForViewInPopover..

Using the apple FFT and accelerate Framework

http://stackoverflow.com/questions/3398753/using-the-apple-fft-and-accelerate-framework

a very great pitch detector as it doesn't have nearly fine enough granularity. There is a cunning trick Extracting precise frequencies from FFT Bins using phase change between frames to get the precise frequency..

How do I apply a perspective transform to a UIView?

http://stackoverflow.com/questions/347721/how-do-i-apply-a-perspective-transform-to-a-uiview

need to work with the UIView's layer using a CATransform3D to perform the layer's rotation. The trick to get perspective working as described here is to directly access one of the matrix cells of the CATransform3D..

Play sound on iPhone even in silent mode

http://stackoverflow.com/questions/3740528/play-sound-on-iphone-even-in-silent-mode

AVAudioSession sharedInstance setCategory AVAudioSessionCategoryPlayback error nil should do the trick. Note if you play music or sounds then iPod playback will be paused. Once this has been done probably..

iPhone app in landscape mode

http://stackoverflow.com/questions/402/iphone-app-in-landscape-mode

IT DOES NOT WORK AND THAT'S THAT. The machine will never rotate the view to landscape. There is no trick fix even Apple cannot make it work. The workaround you must adopt is having an overall UIViewController..

Change iOS app's language on the fly

http://stackoverflow.com/questions/6150576/change-ios-apps-language-on-the-fly

iphone objective c ios localization xcode4 share improve this question This should do the trick assuming that de is the new language selected by the user. Also assure that you are reinitiating the..

Xcode 4 - “Valid signing identity not found” error on provisioning profiles on a new Macintosh install

http://stackoverflow.com/questions/6769345/xcode-4-valid-signing-identity-not-found-error-on-provisioning-profiles-on-a

of Xcode and some users have reported that the Refresh button in the lower right corner does the trick. So try clicking Refresh first and if that doesn't help do the export import sequence. Picture for XCode..

Customize the MKAnnotationView callout

http://stackoverflow.com/questions/8018841/customize-the-mkannotationview-callout

create a custom callout but we can create an annotation with a completely customized view. So the trick is to add a second annotation when the first is selected and make the 2nd annotation view look like..

How do you optionally use iPhone OS 3.0 features in a 2.0 compatible app?

http://stackoverflow.com/questions/986589/how-do-you-optionally-use-iphone-os-3-0-features-in-a-2-0-compatible-app

linking of the MapKit.framework weak_framework MapKit . I found it quite cumbersome since I had to trick the compiler linker to use the 2.0 SDK with all code except the one which uses MapKit. Has anybody more..

How to make a UITextField move up when keyboard is present

http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present

up or down. Do I need both a UIView and a UIScrollView Does one go inside the other EDIT I now know that you want a UIView inside of a UIScrollView and the trick is to programatically set the content size of the UIScrollView to the frame size of the UIView . Then what needs to be implemented in order to automatically scroll..

UIScrollView horizontal paging like Mobile Safari tabs

http://stackoverflow.com/questions/1220354/uiscrollview-horizontal-paging-like-mobile-safari-tabs

centers based on multiples of the UIScrollView 's width. Then since you want to see the other pages of course set clipsToBounds to NO as mhjoy stated. The trick part now is getting it to scroll when the user starts the drag outside the range of the UIScrollView 's frame. My solution when I had to do this very recently was..

Getting thumbnail from a video url or data in IPhone SDK

http://stackoverflow.com/questions/1347562/getting-thumbnail-from-a-video-url-or-data-in-iphone-sdk

this question is that one can now with 4.0 iOS get thumbnails using AVFoundation the following code where the class property url is the movie url will do the trick you can get the thumbnail at any time in the example its at time 0 void generateImage AVURLAsset asset AVURLAsset alloc initWithURL self.url options nil AVAssetImageGenerator..

How do I detect when someone shakes an iPhone?

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

iphone ios accelerometer shake motion detection share improve this question In 3.0 there's now an easier way hook into the new 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..

Is there a documented way to set the iPhone orientation?

http://stackoverflow.com/questions/181780/is-there-a-documented-way-to-set-the-iphone-orientation

so as I swapping the views out I would like to force the rotation to be set to portrait. There is an undocumented property setter on UIDevice that does the trick but obviously generates a compiler warning and could disappear with a future revision of the SDK. UIDevice currentDevice setOrientation UIInterfaceOrientationPortrait..

Creating a left-arrow button (like UINavigationBar's “back” style) on a UIToolbar

http://stackoverflow.com/questions/227078/creating-a-left-arrow-button-like-uinavigationbars-back-style-on-a-uitoolba

customView property of the toolbar item. Works well for me. Edit As pointed out by PrairieHippo maralbjo found that using the following simple code did the trick requires custom image in bundle should be combined with this answer. So here is additional code Creates a back button instead of default behaviour displaying title..

How to intercept click on link in UITextView?

http://stackoverflow.com/questions/2543967/how-to-intercept-click-on-link-in-uitextview

Objective-C categories in static library

http://stackoverflow.com/questions/2567498/objective-c-categories-in-static-library

setting all_load or ObjC flag. He just add to category h m files empty dummy class interface implementation to force linker use this file. And yes this trick do the job. But author also said he even not instantiated dummy object. Mm As I've found we should explicitly call some real code from category file. So at least..

underline text in UIlabel

http://stackoverflow.com/questions/2711297/underline-text-in-uilabel

Popover with embedded navigation controller doesn't respect size on back nav

http://stackoverflow.com/questions/2752394/popover-with-embedded-navigation-controller-doesnt-respect-size-on-back-nav

when you will navigate back between the controllers. You could easily create category on UIViewController with the following helper method that would do the trick with setting the size void forcePopoverSize CGSize currentSetSizeForPopover self.contentSizeForViewInPopover CGSize fakeMomentarySize CGSizeMake currentSetSizeForPopover.width..

Using the apple FFT and accelerate Framework

http://stackoverflow.com/questions/3398753/using-the-apple-fft-and-accelerate-framework

around that frequency. So as you can see it wouldn't be a very great pitch detector as it doesn't have nearly fine enough granularity. There is a cunning trick Extracting precise frequencies from FFT Bins using phase change between frames to get the precise frequency for a given bin. Ok Now onto the code Note the 'ip'..

How do I apply a perspective transform to a UIView?

http://stackoverflow.com/questions/347721/how-do-i-apply-a-perspective-transform-to-a-uiview

animation share improve this question As Ben said you'll need to work with the UIView's layer using a CATransform3D to perform the layer's rotation. The trick to get perspective working as described here is to directly access one of the matrix cells of the CATransform3D m34 . Matrix math has never been my thing so I can't..

Play sound on iPhone even in silent mode

http://stackoverflow.com/questions/3740528/play-sound-on-iphone-even-in-silent-mode

AVFoundation AVFoundation.h at the start of your file and AVAudioSession sharedInstance setCategory AVAudioSessionCategoryPlayback error nil should do the trick. Note if you play music or sounds then iPod playback will be paused. Once this has been done probably somewhere in the initialisation of one of your classes that..

iPhone app in landscape mode

http://stackoverflow.com/questions/402/iphone-app-in-landscape-mode

happyThing.view and instead put in there newThing.view IT DOES NOT WORK AND THAT'S THAT. The machine will never rotate the view to landscape. There is no trick fix even Apple cannot make it work. The workaround you must adopt is having an overall UIViewController that simply sits there and just holds your various views..

Change iOS app's language on the fly

http://stackoverflow.com/questions/6150576/change-ios-apps-language-on-the-fly

.strings file so that NSLocalizedString works appropriately iphone objective c ios localization xcode4 share improve this question This should do the trick assuming that de is the new language selected by the user. Also assure that you are reinitiating the current view. NSUserDefaults standardUserDefaults setObject..

Xcode 4 - “Valid signing identity not found” error on provisioning profiles on a new Macintosh install

http://stackoverflow.com/questions/6769345/xcode-4-valid-signing-identity-not-found-error-on-provisioning-profiles-on-a

Customize the MKAnnotationView callout

http://stackoverflow.com/questions/8018841/customize-the-mkannotationview-callout

I understand you want a pin with a custom callout. We can't create a custom callout but we can create an annotation with a completely customized view. So the trick is to add a second annotation when the first is selected and make the 2nd annotation view look like a callout bubble. This is the solution posted by users djibouti33..

How do you optionally use iPhone OS 3.0 features in a 2.0 compatible app?

http://stackoverflow.com/questions/986589/how-do-you-optionally-use-iphone-os-3-0-features-in-a-2-0-compatible-app

do not want to update yet. I experimented a bit with weak linking of the MapKit.framework weak_framework MapKit . I found it quite cumbersome since I had to trick the compiler linker to use the 2.0 SDK with all code except the one which uses MapKit. Has anybody more experience with this What are you doing to make it compile..

How to make a UITextField move up when keyboard is present

http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present

a UIScrollView Does one go inside the other EDIT I now know that you want a UIView inside of a UIScrollView and the trick is to programatically set the content size of the UIScrollView to the frame size of the UIView . Then what needs to be implemented..

UIScrollView horizontal paging like Mobile Safari tabs

http://stackoverflow.com/questions/1220354/uiscrollview-horizontal-paging-like-mobile-safari-tabs

's width. Then since you want to see the other pages of course set clipsToBounds to NO as mhjoy stated. The trick part now is getting it to scroll when the user starts the drag outside the range of the UIScrollView 's frame. My solution..

Getting thumbnail from a video url or data in IPhone SDK

http://stackoverflow.com/questions/1347562/getting-thumbnail-from-a-video-url-or-data-in-iphone-sdk

4.0 iOS get thumbnails using AVFoundation the following code where the class property url is the movie url will do the trick you can get the thumbnail at any time in the example its at time 0 void generateImage AVURLAsset asset AVURLAsset alloc..

How do I detect when someone shakes an iPhone?

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

detection share improve this question In 3.0 there's now an easier way hook into the new 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...

Method Swizzle on iPhone device

http://stackoverflow.com/questions/1637604/method-swizzle-on-iphone-device

throw a bunch of errors when I try to compile for Device 3.x Has anyone had any luck swizzling on the iphone Whats the trick TIA iphone objective c swizzling share improve this question The CocoaDev wiki has an extensive discussion on method..

Is there a documented way to set the iPhone orientation?

http://stackoverflow.com/questions/181780/is-there-a-documented-way-to-set-the-iphone-orientation

like to force the rotation to be set to portrait. There is an undocumented property setter on UIDevice that does the trick but obviously generates a compiler warning and could disappear with a future revision of the SDK. UIDevice currentDevice..

Creating a left-arrow button (like UINavigationBar's “back” style) on a UIToolbar

http://stackoverflow.com/questions/227078/creating-a-left-arrow-button-like-uinavigationbars-back-style-on-a-uitoolba

Works well for me. Edit As pointed out by PrairieHippo maralbjo found that using the following simple code did the trick requires custom image in bundle should be combined with this answer. So here is additional code Creates a back button instead..

How to intercept click on link in UITextView?

http://stackoverflow.com/questions/2543967/how-to-intercept-click-on-link-in-uitextview

Objective-C categories in static library

http://stackoverflow.com/questions/2567498/objective-c-categories-in-static-library

just add to category h m files empty dummy class interface implementation to force linker use this file. And yes this trick do the job. But author also said he even not instantiated dummy object. Mm As I've found we should explicitly call some..

underline text in UIlabel

http://stackoverflow.com/questions/2711297/underline-text-in-uilabel

Popover with embedded navigation controller doesn't respect size on back nav

http://stackoverflow.com/questions/2752394/popover-with-embedded-navigation-controller-doesnt-respect-size-on-back-nav

controllers. You could easily create category on UIViewController with the following helper method that would do the trick with setting the size void forcePopoverSize CGSize currentSetSizeForPopover self.contentSizeForViewInPopover CGSize fakeMomentarySize..

Using the apple FFT and accelerate Framework

http://stackoverflow.com/questions/3398753/using-the-apple-fft-and-accelerate-framework

see it wouldn't be a very great pitch detector as it doesn't have nearly fine enough granularity. There is a cunning trick Extracting precise frequencies from FFT Bins using phase change between frames to get the precise frequency for a given..

How do I apply a perspective transform to a UIView?

http://stackoverflow.com/questions/347721/how-do-i-apply-a-perspective-transform-to-a-uiview

As Ben said you'll need to work with the UIView's layer using a CATransform3D to perform the layer's rotation. The trick to get perspective working as described here is to directly access one of the matrix cells of the CATransform3D m34 . Matrix..

Accessing iPhone WiFi Information via SDK

http://stackoverflow.com/questions/351954/accessing-iphone-wifi-information-via-sdk

Play sound on iPhone even in silent mode

http://stackoverflow.com/questions/3740528/play-sound-on-iphone-even-in-silent-mode

of your file and AVAudioSession sharedInstance setCategory AVAudioSessionCategoryPlayback error nil should do the trick. Note if you play music or sounds then iPod playback will be paused. Once this has been done probably somewhere in the initialisation..

iPhone app in landscape mode

http://stackoverflow.com/questions/402/iphone-app-in-landscape-mode

there newThing.view IT DOES NOT WORK AND THAT'S THAT. The machine will never rotate the view to landscape. There is no trick fix even Apple cannot make it work. The workaround you must adopt is having an overall UIViewController that simply sits..

Change iOS app's language on the fly

http://stackoverflow.com/questions/6150576/change-ios-apps-language-on-the-fly

works appropriately iphone objective c ios localization xcode4 share improve this question This should do the trick assuming that de is the new language selected by the user. Also assure that you are reinitiating the current view. NSUserDefaults..

Xcode 4 - “Valid signing identity not found” error on provisioning profiles on a new Macintosh install

http://stackoverflow.com/questions/6769345/xcode-4-valid-signing-identity-not-found-error-on-provisioning-profiles-on-a

manage this aspect of Xcode and some users have reported that the Refresh button in the lower right corner does the trick. So try clicking Refresh first and if that doesn't help do the export import sequence. Picture for XCode 4.6 added by WP..

Customize the MKAnnotationView callout

http://stackoverflow.com/questions/8018841/customize-the-mkannotationview-callout

callout. We can't create a custom callout but we can create an annotation with a completely customized view. So the trick is to add a second annotation when the first is selected and make the 2nd annotation view look like a callout bubble. This..

How do you optionally use iPhone OS 3.0 features in a 2.0 compatible app?

http://stackoverflow.com/questions/986589/how-do-you-optionally-use-iphone-os-3-0-features-in-a-2-0-compatible-app

a bit with weak linking of the MapKit.framework weak_framework MapKit . I found it quite cumbersome since I had to trick the compiler linker to use the 2.0 SDK with all code except the one which uses MapKit. Has anybody more experience with..