How to Extract the information about UI elements during runtime of an iOS application? - iphone

Is there any way that one could extract the information about UI elements (of the UIView) from the application’s memory during runtime of an iOS application (iPhone). Like getting a reference to the current UIView element and find a way to enumerate all UI elements contained in that view and create an abstract graph of the UIView calls of the app dynamically?

Since it looks like you may be interested n some general suggestions, I'll give you this one: look at DCIntrospect (available on github, with good documentation).
With this open source software, you can examine any item in your UI that subclasses UIView. You can see its many properties in your console.
It is very easy to use. I tried it, and it was a very simple add to my application delegate. To enable it, you press the space bar on your keyboard.
Since it is open source, you can examine the code and see for yourself what UI element properties are available and even make changes yourself.

UIView comes with an undocumented function to do that: -recursiveDescription. It's not as pretty as DCIntrospect, but you don't have to add anything to your project. Simply do:
NSLog(#"%#", [view recursiveDescription]);
or you can call it from the debugger:
p [view recursiveDescription]
See Apple's Technical Note 2239 (scroll to the bottom) for more details, and other interesting debugging commands.

Related

Google Maps APi for iOS: UIActivityView on custom info window

I'm trying to put a spinner inside a custom info window that appears when the user presses a marker. I have a custom view for the window that has lots of subviews that show up fine. But when I try to add a UIActivityView or an animated PNG sequence, that doesn't show. Has anyone else experienced this?
The documentation on the mapView:markerInfoWindow: method says:
If you change this view after this method is called, those changes
will not necessarily be reflected in the rendered version.
It seems likely that the Google map is not showing the actual UIView you return, but a screenshot of it taken when the info window is returned by the delegate.
As mentioned in this answer, this is made explicit in the Android documentation - it seems likely that the Android and iOS SDKs work similarly.
If you've changed the view I'm not sure if there is a way to force the SDK to take a new screenshot of it. Possibly you could try setting the map's selected marker to nil and then back to your marker, to see if it then calls mapView:markerInfoWindow: again - although it might also re-centre the marker on the map when you do that. It also likely wouldn't be very efficient.
You can call mapView:markerInfoWindow: then inside the method you can create a UIView which you can add different controls on that UIView including the spinner. You can also specify on which location you would like to put the defined control.

Implementing uitable like iphone email overview

I have a table (UITableView) and shall implement therefore the functions like in the iphone email-interface. This means: In the header right up I need a edit-button. When pressed, some cells can be marked and in the footer there appear several buttons.
Is there a library, where I can take the functionality from? If not, any idea, how I can Implement the "marking function"?
There's a cool example among the apple docs, which I guess meets well your request. Inspect it, I think you'll find much useful there:
http://developer.apple.com/library/ios/#samplecode/iPhoneCoreDataRecipes/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008913

iOS - QuickLook - How to open an object in QuickLook without a UIScrollView

Could anyone point me towards a resource which uses QuickLook to open a (preferably but not necessarily a pdf) file without using a UITableView?
I do have this example of using QuickLook but it uses a listview which I need to get away from.
http://robsprogramknowledge.blogspot.com/2011/02/quick-look-for-ios_21.html
I'm not sure how you plan to design your UI to open a file. I've used a few different ways, so I'll toss out some ideas. A UITableView is ideal for large amounts of files. A generic scroll view can also be used for a large number of files. I've used an alert view for an app that only generates one or two files. You could also use a view with document icons like the iPad Mail app. To get the document icons, use UIDocumentInteractionController. The WWDC 2010 DocInteraction sample code goes in great depth with how to use UIDocumentInteractionController.
As for opening the file, the Quick Look framework makes that easy. A simple, self-contained solution is to subclass QLPreviewController. Then, your subclass needs to conform to the QLPreviewControllerDataSource protocol and optionally the QLPreviewControllerDelegate protocol. Next, pass it an array of NSURLs pointing to your files. You can do this either through an initializer like -initWithFiles:(NSArray *)files or through a setter. From here, -previewController:previewItemAtIndex: just needs to index into the array to get the appropriate file to show. -numberOfPreviewItemsInPreviewController: just needs to return the size of the array. Once you have this class finished, you can use any UI design you like to push this view or present it modally.
Hopefully this is more clear than my tutorial you've been reading.
EDIT:
I have posted some code to Github that may help you. I have created a file previewer class as described above. I also posted a demo app that directly uses a QLPreviewController.

Create springboard like main view

Is there some sample code, or an easy way, to implement an application with as its first view something like Springboard?
What I am looking for is just a view with basic icons which after a tab on an icon tells the view-controller to push the view associated with the selected icon.
This in itself is not that difficult off-course (just putting images on a view), but is there an easy way to implement all the extra functionality as well (as e.g. moving the icons around (start 'vibrating' when when you push hold them), multiple pages etc.). The Facebook App seems to have this. It is probably not worth my while to write it myself, but it would be nice if there is something 'out of the box' to give the App a bit more of an iPhone feel.
Thanks in advance!
Facebook uses the Three20 library for its UI. The specific view used for the SpringBoard-like interface is known as TTLauncherView.
This is not an endorsement (I have yet to really check this out, and I may be too entrenched in using Three20 at this point to even bother), but here is another project that implements the springboard functionality: myLauncher on Github
You can use UICollectionView to create this
Look at this example
https://github.com/tularovbeslan/Springboard

How to simulate a mouse click on a UIWebView in Cocoa for the iPhone?

I'm trying to setup automated unit tests for an iPhone application. I'm using a UIWebView and need to simulate clicks on different links. I've tried doing this with JavaScript, but it doesn't produce the same result as when I manually click on the links. The main problem is with links that have their target property set.
When you manually click on a standard "popup" link (e.g. <a href="http://example.com" target="_blank">), the UIWebView will ignore the click event and won't navigate to anything. If you then try clicking on this very same link automatically via the JavaScript dispatchEvent() method, the UIWebView will completely ignore the target attribute and will open up the link normally in the current page.
I need an my automatic unit testing to produce the exact same results as when you manually click a link.
I believe the only way for this automated unit test to work correctly is to simulate a mouse click at a specific x/y coordinate (i.e. where the link is located). Since the unit testing will only be used internally, private API calls are fine.
It seems like this should be possible since the iPhone app isimulate seems to do something similar.
Is there any way to do this in the framework?
I found a similar question titled Simulate mouse click to window instead of screen, however I'm guessing this method is only valid for OS X, and not for iPhone OS.
I suppose you could simulate the touches by calling the touchesBegan/touchesEnded methods directly on the UIView (check the UIResponder class).
The proper way to do this would be to construct your own UIEvent and then post this event to your UIApplication instance via its -sendEvent: method.
However, there doesn't appear to be a public API for constructing a UIEvent, so you might be out of luck.
Could you store the locations of the clicks in a data structure that you use in your tests and then simulate standard touch events as described here described here
--- Just spotted that you didn't have much luck with the example on this link. The only other options I can suggest would be to manipulate the html when running from a test to replace any _target links (you know that UIWebView handles these properly when clicking manually, so I think a small bodge is ok for the unit test?).
Nice walkthrough in this answer
For your specific case, it may be sufficient to test in the simulator and use a MacOS event generator to make the clicks.
The private calls for recording and sending events are part of GraphicServices/GSEvent.h with the standard use at your own risk disclaimers. Every UIEvent is really a UIInternalEvent that has a reference to a __GSEvent, so for recording you can use the _gsEvent property to get the underlying event.
#property (nonatomic,assign) struct __GSEvent *_gsEvent;
I have not used any of this stuff, but it looks like GSSendSystemEvent would be a good place to start.