iphone-sdk-3.0

Center UIPickerView Text

梦想与她 提交于 2019-11-30 03:10:42
So I have a uipickerview with rows that only contain the number 0-24 and it looks a bit silly since the numbers are left aligned leaving a huge gap on the right of the pickerview. Is there an easy way to center align text in a uipickerview? - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 37)]; label.text = [NSString stringWithFormat:@"something here"]; label.textAlignment = NSTextAlignmentCenter; //Changed to NS as UI is deprecated.

SKPayementQueue: restoring transactions finishes without calling 'updatedTransactions' in release config but not debug config

时光总嘲笑我的痴心妄想 提交于 2019-11-30 02:45:28
I'm debugging restoring transactions and in my debug configuration everything works normally: IE I call: [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; sometime later the queueCalls: - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions and sometime after that it calls: - (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue { and everyone is happy. BUT in my release configuration, I never see the call to updatedTransactions and so I never actually restore the purchases. possibly related, after I attempt the restore and

how do I detect the iPhone orientation before rotating

血红的双手。 提交于 2019-11-30 02:41:59
In my program I'm moving things based on rotation, but I'm not rotating the entire view. I'm Using : static UIDeviceOrientation previousOrientation = UIDeviceOrientationPortrait; - (void)applicationDidFinishLaunching:(UIApplication *)application { [window addSubview:viewController.view]; [window makeKeyAndVisible]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:@"UIDeviceOrientationDidChangeNotification" object:nil]; } - (void) didRotate:(NSNotification *)notification{ UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; [self

UITabBarController, MoreNavigationController and the Holy Grail of Device Rotation

别来无恙 提交于 2019-11-30 02:30:18
UPDATE: See my answer to this question first. This appears to be a bug. A minimal test case has been created and a report has been filed with Apple. (Fixed as of iPhone OS 3.1.) Here's a puzzler from the "I'm so close!" department. I have a Tab Bar-based iPhone app. Each tab features a UINavigationController with the usual suspects (nav bar, table view ... which in turn can lead to another VC, etc.). Now, one of those lower-level VCs is to be used in portait and landscape modes. But there's a problem. Our landscape-friendly VC's shouldAutorotateToInterfaceOrientation: won't get called out-of

how to show countdown on uilabel in iphone?

久未见 提交于 2019-11-30 02:22:34
i have a uilabel and a uislider on a view. i want to set label's time using slider.range of slider is 00:00:00 to 03:00:00. means 3 hours.and intervel on slider is 0.5 minutes.also how to show.i want the timer runs even if application is closed. First off, there's no way to keep the timer running after your app is closed. Background apps simply aren't allowed on the iPhone. There are ways to fake it with a timer (save a timestamp when the app exits, and check it against the time when it starts back up), but it won't handle the case where your timer runs out before the app is started back up.

How to open UITextView web links in a UIWebView instead of Safari?

我的未来我决定 提交于 2019-11-30 01:59:02
I'm developing and iPhone 3.0 application. And I'm trying to open web links in a UITextView into a UIWebView instead of Safari. But still no luck. The UITextView is not editable, and it perfectly detects web links and open them in Safari. How to avoid that? How to grab that url so i can use with my own UIWebView ? The simplest way is to override the webView:decidePolicyForNavigationAction:request:frame:decisionListener: method on UITextView like so: @interface UITextView (Override) @end @class WebView, WebFrame; @protocol WebPolicyDecisionListener; @implementation UITextView (Override) - (void

MP3 playing using AVAudioPlayer not working on device

隐身守侯 提交于 2019-11-30 01:49:58
I am testing my app on my 3GS iPhone with iOS 4.2 I am using the following code which plays a sound in my IBAction. It works perfectly in the simulator (both iPad and iPhone) - I hear the sound. NSString *pathToMusicFile1 = [[NSBundle mainBundle] pathForResource:@"alarm" ofType:@"mp3"]; NSError *error; alarmSound = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile1] error:&error]; NSLog(@"Song1 Loaded"); if (alarmSound == nil) { NSLog(@"Error playing sound"); } else { alarmSound.numberOfLoops = 20; alarmSound.volume = 1.0; [alarmSound play]; } I have everything

obtaining the rotation and size of a UIImageView based on its transformation matrices

倾然丶 夕夏残阳落幕 提交于 2019-11-30 01:39:00
If I have the original transform matrix of a rectangular UIImageView and this image is scaled and rotated and by the end I can read the final transform matrix of this same view, how can I calculate how much the image scaled and rotated? I suppose that somehow these matrix contain these two informations. The problem is how to extract it... any clues? thanks for any help. A little bit of matrix algebra and trigonometric identities can help you solve this. We'll work forward to generate a matrix that scales and rotates, and then use that to figure out how to extract the scale factors and

iPhone p2p - Is there a way to connect to more than 1 devices?

和自甴很熟 提交于 2019-11-30 00:45:08
Is it possible to connect to more than 1 devices using the new GameKit framework? Till now all the examples I've seen show how we can connect to 1 device. Even the default connection interface lets the user select just one connect. Thanks. There's a fairly good overview here at the following link of how to configure and use GameKit for your App. GameKit Programming Guide: Peer-to-Peer Connectivity Unfortunately, you will not be able to use the GKPeerPickerController standard UI picker to configure the GKSession instance for you if you want to support more than 2 devices. Instead, you must

compare two arrays and get the common items

心已入冬 提交于 2019-11-30 00:16:30
I have two arrays, but they have different lengths . I want to compare these two arrays and put common items to a new array . meanwhile there should not be have duplicate items is the third array. I really mess up with this, please give me a help. highly thankful . . . Something like this? NSMutableSet* set1 = [NSMutableSet setWithArray:array1]; NSMutableSet* set2 = [NSMutableSet setWithArray:array2]; [set1 intersectSet:set2]; //this will give you only the obejcts that are in both sets NSArray* result = [set1 allObjects]; This has the benefit of not looking up the objects in the array, while