uiapplication

Finding the rootViewController in iOS

别来无恙 提交于 2020-01-01 04:37:06
问题 In ShareKit, the code needs to determine where the rootViewController is so it can show a modal view. For some reason, the code is failing in iOS 5: // Try to find the root view controller programmically // Find the top window (that is not an alert view or other window) UIWindow *topWindow = [[UIApplication sharedApplication] keyWindow]; if (topWindow.windowLevel != UIWindowLevelNormal) { NSArray *windows = [[UIApplication sharedApplication] windows]; for(topWindow in windows) { if (topWindow

How to disable popup menu items like Select, Select All, Suggest…, Define (on UIWebView)?

风流意气都作罢 提交于 2019-12-31 03:59:34
问题 How to disable popup menu items like Select , Select All , Suggest... , Define (on UIWebView )? I have found the following information on the help but don't understand how to use it: For the editing menu commands, this is the shared UIApplication object. Depending on the context, you can query the sender for information to help you determine whether a command should be enabled. 回答1: Swizzle the following method: #import "NSObject+myCanPerformAction.h" @implementation NSObject

Setting UIApplication statusBarHidden to YES does not work in iOS 7

折月煮酒 提交于 2019-12-31 02:01:10
问题 I've been using [UIApplication sharedApplication].statusBarHidden = YES; to hide the status bar when users enter specific UIViewControllers in iOS 6 and it worked great. In iOS 7 however it still shows a translucent overlay. 回答1: EDITED::: that is new updated answer : Do in plist file "View controller-based status bar appearance" to NO and write code [UIApplication sharedApplication].statusBarHidden = YES; in appdelegate 回答2: What worked for me was setting "Status bar is initially hidden" to

UIApplicationDidEnterBackgroundNotification

百般思念 提交于 2019-12-30 03:16:05
问题 whats the use of UIApplicationDidEnterBackgroundNotification in iPhone app or how we can take benifit from it 回答1: This notification means the user "quit" your app on an iPhone 4 - It happens when a phone call or text message comes in and user accepts the interruption (answers/replies), or when the user has pressed the Home button. I found this link on SO that shows the interaction between all states, and the appropriate notifications: http://www.drobnik.com/touch/2010/07/understanding-ios-4

How to differentiate lock screen and home button (background multitasking) on applicationWillResignActive in the app delegate

牧云@^-^@ 提交于 2019-12-25 07:47:08
问题 I am writing an alarm clock app. Please correct me if I am wrong: On both events (lock & home button in iOS 4.x) the applicationWillResignActive: method is called. When locked my app can keep on running (forever if DeepSleepPreventer.h is used) to check if the alarm should go off. When home is pressed it has to stop working at some time (apart from some basic background calculations). So in this case I have to set a local UILocalNotification to trigger the alarm. So my question: How to

How send application to background when install on device?

时光怂恿深爱的人放手 提交于 2019-12-24 00:39:16
问题 I am making an application in which i want features like as when i run my app on device then it will closed immediately without showing any screen.But Application works in background. When user click on icon of application then it will not show any screen but work in background. After 2 minutes gap it will show a alert message. How do that? I have used code for this given below:- -(void)applicationDidFinishLaunching:(UIApplication *)application{ [application cancelAllLocalNotifications];

Objective-C project with Swift UIApplication subclass. Error: class not loaded

情到浓时终转凉″ 提交于 2019-12-23 15:28:43
问题 I have a project written in Objective-C and I just added a UIApplication subclass using Swift: RMFApplication.swift (implementation at end of post). However, I am getting this error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to instantiate the UIApplication subclass instance. No class named RMFApplication is loaded.' In my info.plist I correctly specified the name under NSPrincipalClass, and double checked it. I read this answer and then

How can I detect UIStatusBar hide and show?

六眼飞鱼酱① 提交于 2019-12-23 11:50:56
问题 I'm trying to detect hidden and show of iPhone's UIStatusBar but failed. Are there any solution can help me, like KVO or something else? 回答1: You can observe the statusBarHidden property of the shared UIApplication instance. Simple example: - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { // Do something here... } - (void)viewDidLoad { [super viewDidLoad]; [[UIApplication sharedApplication] addObserver:self

How to call (dialing) with “ * ” char in IOS?

亡梦爱人 提交于 2019-12-22 11:07:34
问题 I hope to call with * character. ex> *711313. Currently, I'm using this code: NSString *str = [NSString stringWithFormat:@"tel:%@", tmp]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; I tested two cases: tmp = @"719929292"; //this is ok. make call. tmp = @"*7128282"; //app no reaction. not to call. How can I call with *(star character)? 回答1: The star may have to be encoded for use in a URL. Try %2A

iOS application runs after end of background task

匆匆过客 提交于 2019-12-22 01:20:04
问题 I made custom voip application. Almost everything works nice; but time from time application is restarted. From crash log: Exception Type: 00000020 Exception Codes: 0xbad22222 Highlighted Thread: 4 SBUnsuspendLimit CryptTalkDev[24820] exceeded 15 wakes in 300 sec Highlighted thread call stack: Thread 4 name: com.apple.NSURLConnectionLoader Thread 4: 0 libsystem_kernel.dylib 0x35eab004 0x35eaa000 + 4100 1 libsystem_kernel.dylib 0x35eab1fa 0x35eaa000 + 4602 2 CoreFoundation 0x355d93ec