iOS10 before
iOS11 after
Now in iOS 11, the sizeThatFits method is not called from UINavigationBar subclasses.
Related
I am trying to create a toolbar for my macCatalyst app in SwiftUI.
On Mac my toolbar should be in the same line as the tripleDotMenu (red, orange, green).
Next to it I want to have my different buttons (see the first image)
I managed removing my titlebar using:
.withHostingWindow { window in
#if targetEnvironment(macCatalyst)
if let windowScene = window?.windowScene as? UIWindowScene {
windowScene.titlebar?.toolbar = nil
windowScene.titlebar?.titleVisibility = .hidden
}
#endif
}
But I can see that the titlebar is just invisible and not gone (image 2). I am not sure how can can get buttons in the top bar...
Developing for macOS it happened automatically..
Can someone help me please? A solution in SwiftUI would be amazing.
I have an iOS/MacCatalyst app, using Swift, not SwiftUI. As soon as I started using Xcode 14, and running on macOS 13 (Ventura), my macCatalyst apps showed the navigation bar menu inline with the 3 dots menu as you say you get for your macOS app. What Xcode and macOS are you using?
There are some bugs with the new inline navigation menu so I've actually reverted back to the previous menu bar style for macCatalyst which has it below the 3 dots section. I did this by inserting
self.navigationController?.navigationBar.preferredBehavioralStyle = .pad
I'am implementing a simple program with QT5.5 which contains a HTML window (QWebview) like the following screenshot:
HTML window on the right side
Now I want the program also installed for iOS e.g. for iPad. I found that the QWebview class isn't available for mobile system, so I had to change my HTML window to QQuickView with QML files (or is there a better way?). I found the following code online:
QQuickView *view = new QQuickView();
QWidget *container = QWidget::createWindowContainer(view, this);
container->setMinimumSize(200,400);
container->setMaximumSize(200,400);
container->setFocusPolicy(Qt::TabFocus);
view->setSource(QUrl("qrc:///webview.qml"));
layout->addWidget(container);
Then i added the container to the mainWindow.
The webview.qml:
import QtQuick 2.5
import QtWebView 1.0
Rectangle {
id: rectangle
width: 200
height: 400
WebView {
id: webview
url: "file:///test.html"
anchors.fill: parent
width: 200
height: 400
}
}
But somehow I can't get the layout right.
HTML window on iOS
There is a blank/white rectangle behind the container, and the container is also not in the HTML window on the right side where it should be. When I change the width and the height of the rectangle in the qml file, it only changes the size of the webview, not the white background.
Can anyone tell me, how can I get this right? I have also used container->setParent() but the view is always on the left.
The visibility of the author's code is maybe not enough but overall it is easier to set the widget in layout with certain alignment. This way you command the widget to be on certain side and make the placement not to depend on coordinates / host widget size etc. The layout variable is assumed to be horizontal box layout or QHBoxLayout.
// make sure that QHBoxLayout* layout = new QHBoxLayout(this);
// or set the horizontal layout somehow else
QQuickView *view = new QQuickView();
QWidget *container = QWidget::createWindowContainer(view, this);
container->serFixedWidth(200); // the layout is horizontal
// and we *may* want to fix the width
container->setFocusPolicy(Qt::TabFocus);
view->setSource(QUrl("qrc:///webview.qml"));
layout->addWidget(container, Qt::AlignRight); // align to the right
Mind that the rest of horizontal layout should be filled like that with respecting relative positions in it.
Has anyone been able to resize the content view for an iOS 7 UITabBarController? In previous versions it consisted of two views. A UITabBar and a UITransitionView. The transition view was the content view. However as of iOS 7 SDK the UITransitionView is fullscreen and setting its size does nothing.
I need to resize the content view as I want to display an ad above the UITabBar.
I managed to reach the actual content view on iOS 7 (inside the UIViewControllerWrapper) via this
UIView *viewToResize = [[transitionView.subviews[0] subviews] objectAtIndex:0];
WHen you then resize that view, you should obtain the same effect as resizing the UITransitionView.
I would like to display the ActionBar alone without any navigation buttons(Home, back,etc) which are present at the bottom of the screen.
If I use '#android:style/Theme.NoTitleBar.Fullscreen', then even the ActionBar is not present.
Is there a way to display ONLY the ACTIONBAR without the navigation bar at the bottom?
For hiding the Navigation Bar, which is there only since API 14, see this
I want to include cocos2d scene besides UIKit GUI elements in my app using kobold2d library, so it should take just part of the screen.
I alter cocos2d glview size like this when initializing the first layer:
UIView * glView = [[CCDirector sharedDirector]view];
CGRect rct = CGRectMake(100, 100, 300, 400);
[glView setFrame:rct];
The view is displayed properly until I change orientation, then glview again becomes fullscreen. Is there a way to disable this behaviour?
XCode 4.5.2, iOS 6, Kobold2D 2.04
Calling reshape after setting the frame might help:
UIView * glView = [[CCDirector sharedDirector]view];
CGRect rct = CGRectMake(100, 100, 300, 400);
[glView setFrame:rct];
[glView reshape];
Now after some experiments I kind of found solution, please correct me if I am wrong. At least this worked for me, hope someone else makes use of it either.
CCDirectorIOS is a UIViewController, and it is usually being set as a rootViewController of app window.
Looks like [window rootViewController] is responsible for making it's view fullscreen every time orientation changes, thus forcing all children to layout (I knew that!!! %).
Therefore, to avoid glView shrinking to the whole window now and then, give window another UIViewController as a rootController, not the CCDirector. That another UIViewController should have it's own brand new UIView. This new rootView is what this rootViewController can resize however he wants, leave alone our glView. Now, assign director as a child of rootController and assign glView as a child of a rootView.
Set glView to size You want - and off we go! Now when rootView resizes, glView doesn't. In my case it still had to resize while maintaining free space proportions so i used setAutoresizingMask on it. please gurus tell what You think.
known caveats:
rootController and navController of KKAppDelegate not used except for proper initial orientation
this raises bar of least ios version to 5 because of addChildViewController: method
the code inside app's AppDelegate (suppose ARC is ON):
-(void) initializationComplete
{
#ifdef KK_PLATFORM_IOS
RootViewController * rootvc = [[RootViewController alloc]init];
UIView * rootView = [[UIView alloc]init];
[rootvc setView:rootView];
[rootvc.view setBackgroundColor:[UIColor blueColor]];//to see views in colors
[window setRootViewController:rootvc];
[rootvc addChildViewController:[CCDirector sharedDirector]];
UIView * glview = [[CCDirector sharedDirector]view];
[rootvc.view addSubview:glview];//[[CCDirector sharedDirector]openGLView]];
CGRect glRect = CGRectInset(rootvc.view.bounds, 50, 50);//our glview frame is smaller than rootView frame
[glview setFrame:glRect];
[glview setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];//so the view size follows window's size even though it's not fullscreen
#endif
}