using iPhone SDK 4.0, how does one determine if a UIViewController is currently in the viewDidAppear state (currently visible). I could set a flag but was wondering if there is a better way.
Thanks.
Nope, setting a flag is the best way, as you never know if something is in front of it.
Have fun!
Related
I just learned about UICollectionView after creating the same functionality in a custom class. So I am thinking about using deleting all that code I wrote and just using UICollectionView.
I know my app gets a lot of installs on iOS 5. And I know a lot non tech savvy friends and family still have it installed.
I googled this and it says I can use some other's guys library(another thing I should have known before writing my custom class). But the answer was not definitive.
So my question is, does Apple include a bridge for iOS 5 or will my app just fail if I use UICollectionView?
I have my target deployment set to 5.0 and it is not giving me any warnings.
Venkat
UICollectionView is iOS6 only. You can include extra code to check for iOS6 and use your custom class on iOS5. But there is no way to use an actual UICollectionView in iOS5.'
Thats what that "other guy's library" does. It has an iOS5 compliant clone of UICollectionView and checks based on the OS which to use.
Maybe you want to try this as an alternative:
https://github.com/steipete/PSTCollectionView
I am trying to write an iPhone app using Delphi XE2 / FireMonkey and have got past many of the initial hurdles, but am now stuck on gesture handling.
I have created a test app with a TVertScrollBox, but I cannot scroll the contents, unless I enable the scroll bars (which are very thin), and touch those. This is not very iPhone friendly (and almost unusable). Would appreciate a pointer in the right direction.
Documentation seems to suggest using UIGestureRecognizer...
http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html
...however these need to be attached to a View, whereas the app is using a FireMonkey form.
Any thoughts would be appreciated.
I have worked out how to do this...
The TVertScrollBox control needs to have the MouseTracking property set to True.
All controls added to the TVertScrollBox then need to have their HitTest property (if it exists) set to False. After that it just works!
With Delphi Xe3, Fire monkey as support for basic gestures (zoom, rotation, pan)
But officially Xe3 doesn't support anymore "IOS" as a target.
You have to wait beginning of 2013 for the release of their "mobile studio" extension
Gestures not in FireMonkey at the moment.
Here are my issues,
When I install my application on my test device it has the behaviour I want.
However if I close it with the IPhone main button and restart with the icon, it starts back from the view where I left it, whereas I would like it to restart from my main view controller (my start view).
In the same way, I load some animations with viewDidLoad in certain views. I want them to show only the first time the view is loaded each time the application is launched. Right now animations only works the first time the application is launched after installation, then they don't screen anymore when I launch again the application.
Does anyone have a clue ?
Thank you very much for your help.
(Sorry if this topic is a bit easy for you guys :D, I'm quite new at it !)
No problem about being new! This is happening because, for devices from iOS 4.0 on up, your app will support multitasking by default. To disable this features, Add the key
UIApplicationExitsOnSuspend
to your Info.plist file, and set its value to YES. Good luck!
In addition to Sam's answer above, you can also add a key named:
Application does not run in background and set the value to YES.
Both work fine, however.
Im trying to simulate a touch on as UIWebView, how can I programmatically fire a touch event at a certain location? (x and y coordinates)
Just call touchesBegan?
Ideally I'd like to do it without any javascript hack because in the future it may not be a uiwebview
It's not easy to synthesize a touch event on the iPhone: you have to use undisclosed API, so you have a high probability of breaking on every update of the iOS and getting rejecting from Apple.
Here's a link that demonstrates how to synthesize a touch event on the iPhone:
Here's another question on StackOverflow: How to send a touch event to iPhone OS?
It's worth pointing out the KIF framework here. It's intended to run in the simulator but part of the code is simulating touch evens in code. with luck, this will be a good starting point.
https://github.com/square/KIF
Specifically, look at stepToTapViewWithAccessibilityLabel in KIFTestStep.m and the line
[view tapAtPoint:tappablePointInElement];
What you need to do is first create the events you want, and then send them to SpringBoard over the "purple port" eg. mach port. To make them system wide you must forward them to each application over the port. That means you need to actually do what the windowmanager does and looking at which app is active, screen locked, etc.
There are a hand full of private framework APIs that work (IOSurface, GraphicServices, SpringBoardServices, etc.) to get you the pieces you need.
You will have to load these private frameworks at runtime using something like dlopen().
This is 100% possible without jailbreak as of iOS 6.1.4 (current ATM), but you will be loading private frameworks which is not allowed by apple for AppStore ;)
It is possible. Exactly how you mentioned, using GSEvents and sending them to the purple named port of the aplication you are trying to control/simulate. Of course you need KennyTM's GSEvent.h to accomplish this.
I've done this for iOS 4.3, just by changing some of the values that Kenny had (like kGSHandInfoTypeTouchDown), but now I'm trying to do it for iOS 5 and it's not working, till now.
EDIT: It is now working for iOS 5.1.
Without jailbreaking there is no real way to hook a gesture recognizer into all views of the entire system. First off, your app running in the background doesn't have the ability of executing this code.
I created a Settings.bundle in my app where the user can change some properties like font size. It works.
But when I leave my App, and I change my setting, I don't know how I can get notified of the change.
For the moment, I create a function call each time a view is loaded that check for app settings.
But I wonder if there is an other and proper way to do this.
You should use your app delegate's application:didFinishLaunchingWithOptions:, or an equivalent location, to check your NSUserDefaults values, or just read them in a UIViewController viewDidLoad method.
While there is no multi-tasking, this is more than adequate. On MacOS X Cocoa we use KVO and bindings to check for changes during the execution of an application; no doubt something similar will work for 4.0 if required.
I finally found the solution. Like you said Paul, for 4.0 sdk version, there is something similar and I found it in "UIApplicationDelegate protocol".
Thank you for helping me. ;)