Programatically iterate all windows/views in an iOS application - c++

I'm a C++/Windows developer getting to grips with iOS AND OBJ-C... can anyone provide sample code how I could iterate through all windows/views belonging to my application and log/print to the debugger some vital information about the size, position, state, etc of each. I'm using a 3rd-party library and am not really understanding exactly what it is creating on my behalf.

In the debugger, you can try:
po [[[UIApplication sharedApplication] keyWindow] recursiveDescription]

Try this:
po [[UIApplication sharedApplication] windows]

Related

Bring QProcess window to front (running Qt Assistant)

My Qt application starts a QProcess that runs Qt Assistant.
I am using Linux (Ubuntu/Neon/KDE) but I want the Qt application to run on Windows and other Linux distributions as well.
Now I need a function that allows to bring the Assistant main window to front at the desktop.
I could not find a solution doing this using the QProcess object. Also I could not find a way to do this via Qt Assistant remote control.
How can I do this in a portable way?
If all you need is showing qhc help files along with your application, you can have a look at the Qt Help module, which is used by Assistant itself.
Instead of showing the help in an external application like the Qt
Assistant, it is also possible to embed the online help in the
application. The contents can then be retrieved via the QHelpEngine
class and can be displayed in nearly any form. Showing the help in a
QTextBrowser is probably the most common way, but embedding it in
What's This help is also perfectly possible.
More here

Customize UIAlertController in iOS 8 to include standard elements like UITableView

I am used to customize UIAlertViews through the [alert setValue:someView forKey:#"accessoryView"] method. This creates customizable content for UIAlertViews with custom heights. However it only works on iOS7 and down. In iOS8 the UIAlertController have taken over, and I cannot customize it anymore, it will cut the height of the UIAlertView.
Is it impossible because of misuse of the UIAlertController, or how am I supposed to do it?
I am trying to incorporate a UITableView inside a UIAlertController with UIAlertControllerStyleAlert.
Thx.
I ran into the same issue right now. I looked at the private header for UIAlertController (https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UIAlertController.h) and found a promising property: contentViewController
And it turned out to be exactly the same as accessoryView used to be for UIAlertView, the difference being that you need to assign a UIViewController to this property rather than a UIView.
UIViewController *v = [[UIViewController alloc] init];
v.view.backgroundColor = [UIColor redColor];
[alertController setValue:v forKey:#"contentViewController"];
That piece of code will show a red view on the alert view! Happy UIAlertController customizing ;)
PS. It is a private property but using KVC there shouldn't be a problem App Store wise, I think.
Edit:
Some people complained that this isn't very safe. It's not a public API, so yes, Apple could change it in any release, causing this method to fail.
To make sure your entire app doesn't crash if that happens you could wrap the KVC call in a try block. If the property changes your controller won't show the content view, but it also won't crash:
#try {
[alertController setValue:v forKey:#"contentViewController"];
}
#catch(NSException *exception) {
NSLog(#"Failed setting content view controller: %#", exception);
}
Using this method in production can be risky, and I don't recommend it for important alerts.
I suggest not your wasting time trying to cram additional UI into a place where isn't supposed to be. Based on the last few years of improvements, Apple will probably add a custom view in the next iOS. Until then, have a look at a framework designed to handle this exact situation without subverting any best practices: SDCAlertView
It supports alerts that imitate the native alerts on iOS 7,8,9, including handling all of the nasty edge cases around sizing, button types, rotation, etc. It does support arbitrary custom views within the alert.
I use this library in Yahoo YMPromptKit for custom push notification prompts that look exactly like iOS native. Here's another example:
I think you can easily customize the UIView adding the controls needed and present it modally, unless you have any other specific reason to use only UIAlertController.
https://www.cocoacontrols.com/search?q=UIAlertview
You can do it with just a one of line of code using my UIAlertController category and replace existing alerts in application, check it here.

Painting zone using wxWidgets and FormBuilder

I have task to create client (best if it will be possible to build it for Windows & Linux) for some tools and printing hexagonal map.
I chose wxWidgets to use for that. I downloaded WxFormBuilder, that perfectly helps to create forms and code for them.
But I have to paint hexagonal map somewhere in that form. And I didn't found what item from instrument panel I have to use for that. I can add something like wxPanel one by hands in sources that was automatically created for me, but that is bad idea, because after every change from wxFormBuilder I will need to parse result again by hands.
I'm new with painting and graphic, but believe there have to be solution for that in wxFormBuilder, isn't it?
That's the thing about computer programming: at some time you always have to settle down and write some code. All those applications that promise to write code for you have to be abandoned at some point and you actually have to do some work: you have reached that point. ( Here is a link to more about this )
Here is a brief introduction to writing code to paint the application window in wxWidgets, with a minimal sample code: http://wiki.wxwidgets.org/WxDC

fbDidLogin not firing when called from C++ on iPhone app

I have an app on iOS that works with C++ (a Cocos2DX game). I want to integrate Facebook on it.
I initialize the Facebook iOS SDK as the Facebook developers website indicates it, on a Objective C class. Then I call this Objective-C class from my C++ code, and it seems to work -the Facebook app is opened and asks for authentication and permissions-.
The problem is that the "events" or "callbacks" like fbDidLogin are not called back, or at least I do not have control over them from C++
Do you know if that can be done?
Thks.
Ok, the solution:
All the Facebook related code must be in the AppDelegate.m Then you can access it from anywhere in your code with this instruction:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate FacebookLogin];

How do I put an href link in an IOS App (OpenGL)

My App is written in OpenGL and C++, I do not use XIB file for presentation. So how can I create an href link that the user clicks and takes them someone in the browser?
OpenGL only draws things to the screen. There's no concept of geometric objects. So you'll have to detect a click on the link text and call the appropriate iOS API invoking the URL.
Okay I think I found it:
NSURL *url = [NSURL URLWithString:#"http://www.iphonedevelopertips.com"];
[[UIApplication sharedApplication] openURL:url];