QLPreviewController behaves as an app of its own on Swift - qlpreviewcontroller

I set the View controller-based status bar appearance to NO on info,plist. I also set application.statusBarHidden = true but status bar reappears automatically when the QLPreviewControl is presented. I don't want statusbar on my application. How could it be hidden?

QLPreviewController works for you from the separate system process via XPC. That's why everything you trying to change on it could be not actually changed on the real instance.
Also it manages status bar in its own way depending on full-screen mode (e.g. when you open PDF file and make tap on the navigation bar).
However, you can subclass it and try to override your properties in your own controller.
Try to set/override in subclass following properties:
modalPresentationCapturesStatusBarAppearance = true
prefersStatusBarHidden = true
setNeedsStatusBarAppearanceUpdate()
Could be that you will have to restore status bar hidden state after user tapped on navigation bar to hide and then tapped again to show it.

I had the same problem and found a similar solution. In Objective-C, these steps worked for me:
Subclass QLPreviewController. In the .h file, add #import QuickLook;.
In the .m file, add this method:
- (BOOL)prefersStatusBarHidden {
return YES;
}
In the info.plist, if the Boolean property “View controller-based status bar appearance” is present, set its value to YES.
In your AppDelegate class, add this line to didFinishLaunchingWithOptions:
[UIApplication sharedApplication].statusBarHidden = YES;
If your info.plist file already has "Status bar is initially hidden” set to YES, step 4 may not needed.

Related

Disabling nextcord button

As title says, I'm trying to find a way how to disable the button for the person, who already interacted with it.
Like when it reaches 5 interactions, it turns green. I had checked the GitHub official Nextcord repository and found the counter.py file, which includes the changing button color after the number of interactions. But I still need to find a way how to disable it for user who already interacted. Thanks for any help!
Simply set the disabled property to True and edit the message with the new view.
If using the decorator in a View class it would look like this
button.disabled = True
await interaction.response.edit_message(view=self)

How to add Page Control in watch application

I have seen several apps that is using page control to navigate among screens in watch application. But I wonder how can we add that control in watch interface. Please help.
Use WKInterfaceController.reloadRootPageControllers for this.
Here is example:
WKInterfaceController.reloadRootPageControllers(withNames: ["first", "second"], contexts: nil, orientation: .horizontal, pageIndex: 0)
Call this method to create or modify your app’s page-based interface:
At launch time. Use this method to customize the set of pages you want displayed, and to set the scrolling orientation.
At runtime. Use this method to change the active set of pages or the orientation, adding or removing pages as needed.
NOTE: It's not recommended to uses both navigation types: pages and modal at the same time.

How to add UIAccessibilityTraitHeader properly?

I am working with objective-c/swift and interface builder trying to make my application navigation accessible. I cannot figure out how to get my header to work when you use the accessibility rotor and select "headings." My heading title is set in Interface Builder (IB). Within IB its set in a Navigation Bar > UINavigationItem > Title attribute. I think what I want to do is find a way to add the UIAccessibilityTraitHeader to the UINavigationItem, but you cant do that in IB. I also tried making an outlet then adding the trait manually in viewDidLoad method. This is not working. If anybody could help that would be great!
#IBOutlet weak var menuTitle: UINavigationItem!
override dynamic func viewDidLoad() {
self.menuTitle.accessibilityTraits |= UIAccessibilityTraitHeader;
}
I found out this is a defect with the iOS Simulator (X-Code 6.2). It does not show "Headers" as a trait. It worked fine when I loaded it onto a device and tested it.

Next and previous control button in winAPI to go to next page (c++)

I am creating an winAPI application in c++ I have a photo in preview pane and I want to create two buttons NEXT and PREVIOUS on clicking them I will go to the next page .
Could you please give me the idea how to do that in c++ ??
Do I need to use QT libraray or it can be done using the in built function of WinAPI like -
HWND hwndButton1 = CreateWindow(L"BUTTON",L"NEXT",WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,550,800,100,30,m_hwndPreview,(HMENU)buttonid1,(HINSTANCE)GetWindowLong(m_hwndPreview, -6),NULL);
HWND hwndButton2 = CreateWindow(L"BUTTON",L"PREVIOUS",WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,650,800,100,30,m_hwndPreview,(HMENU)buttonid2,(HINSTANCE)GetWindowLong(m_hwndPreview, -6),NULL);
and then using WM_COMMAND for both the button clicks.
Am I going right?
I just want my API application work like a .pdf extension file...as in PDF files we have up and down arrow and on clicking upon them we can go to the next page..In winAPIc++ I couldn't find any such arrow function.. please tell me if there is any such arrow up/down function present to go to next page (because I am very less interested in creating NEXT and PREVIOUS button using createwindow function.. It looks odd).
You have not mentioned what tools you are using, so we don't know if you have a resouce editor. You should research that in a forum appropriate for the tools. If you think writing one line of code to create a button is "very complicated" then you need a better tool.
If you do not want the buttons to appear on top of the picture then you need another place to put them. One common possibility is a toolbar. It is a strip for buttons along the top or bottom of the main window:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb760435(v=vs.85).aspx
With a resource editor you can draw an arrow on the button. Without a resource editor you can set the button text to a unicode arrow:
SetWindowText(hwndButton1, L"\x25bc"); // down arrow, use 25b2 for up arrow
Most buttons (and other controls) are created using a resource editor, placing the controls on a dialog template or a toolbar resource. If you do that Windows will create the buttons when you create the dialog or toolbar. This method is much preferred because Windows will adjust the size of the buttons as required for the screen settings in use.
If you can't do that you must use CreateWindow as you are doing.
Finally it is done.. I have created the buttons neither using Qt or nor using any createWindowEx..The best and easy approach to follow is resource editor ...just put some button on dialog and use IDD_MAINDIALOG (in my case)
m_hwndPreview = CreateDialogParam( g_hInst,MAKEINTRESOURCE(IDD_MAINDIALOG), m_hwndParent,(DLGPROC)DialogProc, (LPARAM)this);
and then
BOOL CALLBACK AMEPreviewHandler::DialogProc(HWND m_hwndPreview, UINT Umsg, WPARAM wParam, LPARAM lParam)
{
switch(Umsg) // handle these messages
{ .........
}
....
}
and thats done. Very easy task.

Flex4 Right Click Spark List using ContextMenu()

I would like to add custom right clicks to a number of spark list controls.
I have tried the following as an item renderer. (as per the flex 4 cook book).
Full Render code here http://pastebin.com/Kx8tJ1cY
When I right click on the Spark List I simply get the Adobe Default Context menu.
This is the same default behaviour I had before I added any code to this.
Could anyone tell me how to add right clicks to List Items in Flex 4.
Please and Thank you.
I found the problem/solution. You cant use context menus if there are Vboxes or Tab Navigators. Which is insane because it means I cant do relative layout properly or decent variable width design.
Quoted from: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/ui/ContextMenu.html
For example, if a DataGrid control is a child of a TabNavigator or VBox container, the DataGrid control cannot have its own context menu.
Christopher Huyler posted something similar (source code available here). From the article:
Start out by grabbing the Javascript code from Google's code repository.
Step 1 – Setup custom context menu code
Create a new Flex project in Flex Builder. Copy rightclick.js and swfobject.js into the html-template folder of your project. From here, I had to make several changes…
I modified the RightClick.init() function to accept an object and container value as input. This allows me to pass in the name of the application as the object instead of having it be called the same thing every time.
I included rightclick.js and swfobject.js in the header of index.template.html.
I added a new div to the body called “flashcontent”.
I added an onload handler to the body tag to initialize RightClick
I replaced AC_FL_RunContent(…) with new SWFObject(…) making sure to maintain all template variables.
After making these changes, I verified that no right-click context menu appears in my application.
Step 2 – Listen for the rightClick event
Next I added a few lines to the main mxml file of my application to listen for the ExternalInterface event that will be dispatched when I right-click my appliction.
private function handleCreationComplete():void
{
ExternalInterface.addCallback("rightClick", handleRightClick);
}
private function handleRightClick():void
{
Alert.show("Right Click Success!");
}
Step 3 – Dispatch an event to the correct object
Getting the event to the main application is easy, but we actually want the appropriate child object to be notified when the right-click event occurs. Since I am not using any double-click events in my application I decided I would treat every right-click event like a double-click event. Users without a two button mouse (aka Mac users) can simply double-click to get the same menu while users with a two button mouse just have to right-click. Here is how I make sure the event is dispatched to the appropriate object.
private function handleRightClick():void
{
var objects:Array = systemManager.getObjectsUnderPoint(
new Point(mouseX,mouseY));
if (objects.length>0)
{
var object:Object = objects[objects.length-1];
var relatedObject:InteractiveObject;
if (object is InteractiveObject)
relatedObject = object as InteractiveObject;
else if (object.parent && object.parent is InteractiveObject)
relatedObject = object.parent;
var event:MouseEvent = new MouseEvent(
MouseEvent.DOUBLE_CLICK,true,false,mouseX,mouseY,
relatedObject);
object.dispatchEvent(event);
}
}
I hope this helps!

Resources