iphone-sdk-3.0

Question regarding SharedInstance

半世苍凉 提交于 2019-11-27 18:29:13
问题 Hey guys, I wanna ask, what is sharedInstance actually? I mean what is the usage? Currently I'm having some problem in communicating between 2 different files. Here's my question: I have 1 file call A.h/A.m and another file call B.h/B.m A.h need to access some of the data in B.h, so .... is there any possible way I could achieve what I want? Just wonder is it "SharedInstance" able to solve my problem? Looking for reply :) 回答1: sharedInstance could be used for several ways. For example you can

How to get UIViewController of a UIView's superview in iOS?

有些话、适合烂在心里 提交于 2019-11-27 18:01:36
I have a UIViewController in which I have a UITextView added from interface builder. Now I want to push a view when I click on hyperlink or phone number. I am able to detect that which url is clicked using a method I found in stackoverflow. Here is the method @interface UITextView (Override) @end @class WebView, WebFrame; @protocol WebPolicyDecisionListener; @implementation UITextView (Override) - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id <

declaring global variables in iPhone project

ε祈祈猫儿з 提交于 2019-11-27 17:54:41
how can i declare a global NSArray and then use it across my app? There are a couple different ways you can do this: Instead of declaring it as a global variable, wrap it in a singleton object, then have the singleton by available anywhere (by #importing the .h file) Create a .h file, like "Globals.h". In the .h, declare your array as extern NSMutableArray * myGlobalArray; Then in the somewhere else in your app (the AppDelegate is a good place), just do: myGlobalArray = [[NSMutableArray alloc] init]; Then anywhere you need the array, just #import "Globals.h" This is like #2, but without the

How do I tell if my iPhone app is running when a Push Notification is received?

隐身守侯 提交于 2019-11-27 17:43:27
I am sending Push Notifications to my iPhone app, and I'd like a different set of instructions to execute depending on whether the app is already launched or not. I'm new to iPhone development, and while I suspect UIApplication or my project's AppDelegate class has the solution, I haven't found a good answer. Is there an easy way to check for this? The UIApplication delegate has the method - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo which you need to implement. This receives the notification when the app is running. If your app is not

How to detect shake motion in iPhone

孤街醉人 提交于 2019-11-27 17:38:40
问题 On the shake of the iPhone device i want some function to be called, i dont know how to recognize shake so i tried some link and tried this code - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { if(event.type == UIEventSubtypeMotionShake) { NSLog(@"called"); [self.view setBackgroundColor:[UIColor greenColor]]; } } - (BOOL)canBecomeFirstResponder { return YES; } But alas no luck so can you please let me know how i can do the same Thanks and Regards 回答1: As per the above

iPhone StoreKit - invalid product id's

允我心安 提交于 2019-11-27 17:20:55
I'm trying to test In App Purchase within the sandbox environment. In order to test the code I did the following: Created an In App Purchase Test User account under 'Manage Users' in iTunes Connect Created some in app purchase products under 'Manage Your In App Purchases'. I used numeric values and alpha-numeric values for the Product IDs. Loaded the app onto the iPhone, went to Settings->Store and logged out of the regular store and into the test account created in step 1 Set a breakpoint in the ( void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *

How to delete all Annotations on a MKMapView

拟墨画扇 提交于 2019-11-27 17:19:14
Is there a simple way to delete all the annotations on a map without iterating through all the displayed annotations in Objective-c? RocketMan Yes, here is how [mapView removeAnnotations:mapView.annotations] However the previous line of code will remove all map annotations "PINS" from the map, including the user location pin "Blue Pin". To remove all map annotations and keep the user location pin on the map, there are two possible ways to do that Example 1, retain the user location annotation, remove all pins, add the user location pin back, but there is a flaw with this approach, it will

UIView doesn't resize to full screen when hiding the nav bar & tab bar

风流意气都作罢 提交于 2019-11-27 17:15:22
I have an app that has a tab bar & nav bar for normal interaction. One of my screens is a large portion of text, so I allow the user to tap to go full screen (sort of like Photos.app). The nav bar & tab bar are hidden, and I set the the text view's frame to be full screen. The problem is, there is about 50px of white space where the tab bar used to be. You can see if from this screen shot: removed dead ImageShack link I'm not sure what's causing this. The whitespace is definitely not the view behind the text view, as I set it's background color to red just to be sure. What could be causing

iPhone Auto-scroll UITextView but allow manual scrolling also

折月煮酒 提交于 2019-11-27 17:01:46
问题 I have a UITextView that has a lot of content. I have a button that allows the UITextView to automatically scroll + 10 pixels in an NSTimer loop: scrollPoint = CGPointMake(scrollPoint.x, scrollPoint.y + 10); [textView setContentOffset:scrollPoint animated:YES]; This works really well, as the animation makes the scroll rather smooth. I want to allow the user to skip ahead or back by scrolling with their finger, however due to this code after the scroll animation, the scroll snaps back to where

Search and display business locations on MKMapView

大兔子大兔子 提交于 2019-11-27 16:57:19
问题 I'm trying to find a way to search for a business, such as "grocery stores" and display them on a google map around the users current location. This used to be pretty simple with the old URL style of launching the apple map location but I can't find out how to do it with the MKMapView. I understand that I'll need to use the MKAnnotations classes but my problem is with finding the data. I've tried plugging in the URL below to get the info from google but the size of the data seems way too