Once again Xcode IB frustrates developers with unnecessary warnings: I cannot seem to get remove this warning from my Xcode project.
When double clicking the warning it brings up my MainMenu.xib file but gives no reference to what is causing the issue. Any ideas?
EDIT:
I've stripped down much of my .xib for public viewing but still have the error with very few objects. You can find the file here: https://www.dropbox.com/s/r2piuojr86dhlt9/MainMenu.xib?dl=0
This is a warning shown starting from Xcode 7 when UI elements like a label or table view column header use a font style or variation that is on available on older OS (and of course your project is still targeting them).
In my project a table view column header was using system font with "medium" font style variation instead of regular on a project targeting OS X 10.9+.
The weird thing is I had to restart Xcode as Interface Builder refused to change the style of the control. Possibly a small glitch of this early 7.0.1 Xcode version.
Anyway, either setting every control style to Regular or changing your project target to 10.11 should fix the warning.
Once again Xcode IB frustrates developers with unnecessary warnings.
Felt the same way about it too, until I saw how my typography differs in 10.10 compared to 10.11. One thing is true – the message is rubbish without pointing to a problematic storyboard item, see P.S section of the post for a semi-workaround.
Current answer almost gets it, but problem is not with font styles being unavailable in older targets, it's with Xcode not handling them properly, see full blog post for details.
If you want to keep your styles, use custom textfield with custom inspectable property. Open up identity inspector and set custom class to TextField, preferred font weight attribute will show up in attribute inspector, set the required value, build and enjoy the result.
import AppKit
#IBDesignable public class TextField: NSTextField
{
#IBInspectable public var preferredFontWeight: Int = 0
override public func awakeFromNib() {
if #available(OSX 10.11, *) {
return
}
guard
let weight: Int = self.preferredFontWeight where weight > 0,
let font: NSFont = self.font,
let name: String = font.familyName,
let manager: NSFontManager = NSFontManager.sharedFontManager() else {
return
}
// Full details here – https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSFontManager_Class/#//apple_ref/occ/instm/NSFontManager/convertWeight:ofFont:
//
// 1 – ultralight
// 2 – thin
// 3 – light, extralight
// 4 – book
// 5 – regular, display
// 6 – medium
// 7 – demi, demibold
// 8 – semi, semibold
// 9 – bold
// 10 – extra, extrabold
// 11 – heavy
// 12 – black
// 13 – ultrablack
// 14 – extrablack
if let font: NSFont = manager.fontWithFamily(name, traits: manager.traitsOfFont(font), weight: weight, size: font.pointSize) {
self.font = font
}
}
}
If you don't really care about the styles, use regular weight font for all text, it should solve the problem, see my earlier answer for available options.
Related
This is my first iOS app, designed explicitly for the iPhone, not iPad, but apparently Apple won't put it on their store unless it will run on a iPad as well. I'm at a total loss as how to "fix" this. I've searched everywhere for suggestions and nothing I've tried works (including here on StackOverflow). I can run the app in the iPad simulator and get the same results as Apple does, but can't seem to find a fix. This is proving extremely frustrating, especially when one considers that this app won't run on a iPad because it needs access to a cellular network.
I'm using the latest Xamarin for Visual Studios and I'm using Visual Studios 2013. There is no mention of the iPad in Info.plist or anywhere else for that matter
Anyone have any suggestions?
R/
Prescott ....
You are receiving this from Apple because you might have indicated your app is an Universal App.
To indicate your application will only run on iPhones you need to set this in the info.Plist file if using Xamarin Studio. When using Visual Studio this is in the project properties. The option is called "Devices" make sure you select iPhone/iPod from the dropdown list.
Device selection in VS2017
I know you said you are using 2013 but this might give you an idea.
All,
Apple requires that apps run on all iOS platforms. Accordingly I had to add constraints to my storyboard to adjust the location of subviews on each screen. Because adding each constraint is tedious, I used Cirrious Fluent Layout which worked very well for me. Below is the code I used on my screen that included a imageview. This was the most complicated screen to "fix" because (apparently) the imagevies somehow changed all the screen sizes, being an iOS developer novice, I had no idea why this worked, only that it did.
First I needed to add the reference:
using Cirrious.FluentLayouts.Touch;
Code:
//This line is required to turn off all autosizing/positioning
View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
// Get the screen dimensions and the middle of the screen
// for button positioning
var barheight = this.NavigationController.NavigationBar.Bounds.Height;
// Height of the navigation bar
var height = UIScreen.MainScreen.Bounds.Height;
var width = UIScreen.MainScreen.Bounds.Width;
int middle = (int) UIScreen.MainScreen.Bounds.Width / 2;
// We cast to int to truncate float,
// int will convert implictly to float when used (Visual Studio).
var heightavailabletoimageviw = height -74 - 47 - 26 - 60;
// 74 is the height of the banner, 47 is the height of the buttons and
// 26 is the height of the title label plus a 5px gap The rest of the
// screen is available for use by the image view,
// set heightavailabletoimageviw to this value
// Had to subtract 60 because the image view still overlapped
// the buttons, no idea why. Anyone?
// Had to add a constraint to the imageview because if I didn't
// it automatically scaled to the size of the image, not good.
ThePhoto.AddConstraints(
ThePhoto.Width().EqualTo(UIScreen.MainScreen.Bounds.Width),
ThePhoto.Height().EqualTo(heightavailabletoimageviw)
);
// Had to fix the size of the imagebutton otherwise the button size
// scaled to the size of the image
btnPhoto.AddConstraints(
btnPhoto.Width().EqualTo(62f),
btnPhoto.Height().EqualTo(47f)
);
// Now we add the constraints to the viewcontroller to finish up.
View.AddConstraints(
// Can't cover the navigation bar (unless it isn't there, mine is),
// this value sets all other relative positions
Banner.AtTopOf(View, barheight),
Banner.AtRightOf(View, 0),
Banner.AtLeftOf(View, 0),
lblTitle.Below(Banner, 0),
lblTitle.WithSameWidth(Banner),
ThePhoto.Below(lblTitle, 5),
ThePhoto.WithSameWidth(lblTitle),
// I have no idea why, but I had to use negative
// values for the buttons to appear on the screen,
// otherwise they were off screen.
// If anyone could explain this, I would appreciate it.
btnUpload.AtBottomOf(View),
btnUpload.ToLeftOf(View,-60),
// Same here, had to use negative values for button to
// position correctly on the screen
btnPhoto.AtBottomOf(View),
btnPhoto.ToLeftOf(View,-(middle + 31)),
// Again, same thing.
btnMainMenu.AtBottomOf(View),
btnMainMenu.ToRightOf(View,-80)
);
This is how I solved my problem, I re-submitted the app and it now appears on the app store at: https://itunes.apple.com/us/app/oml-photo-manager/id1212622377?mt=8.
Hope this helps someone ....
R/
Prescott ...
Building a Today Widget in iOS, and my view doesn't take up the full width of the screen:
See in the above screenshot that anything that goes beyond that point of the screen gets cut off.
I have set this up using the standard storyboard provided with the Today Widget extension:
This is confusing to me because I see plenty of other app's Today extensions use the full width of the screen.
you need to implement widgetMarginInsetsForProposedMarginInsets: like this
func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
return UIEdgeInsetsZero
}
check Apple Doc - Design the UI
Developing on a Mac with El Capitan and Xcode 7.2:
If I have a project with one Window, that has a SKScene for SpriteKit, then I will get the needed 60 fps and everything works as expected. But as soon as I define a second window with an SKScene in it, then I will have only 30 fps in my first window, even if the second window is not used at all and not even a Referencing Outlet for the second window is defined. The second window only exists in MainMenu.xib and is not used at all.
I need four Sprite Kit Windows with one scene in it for my projects, so I get a very poor updating performance. Programs work fine with Yosemite but as soon as I run them in El Capitan this problem occurs.
I would be very lucky for any suggestions. Problem is the same in older Xcode versions and the newest one (7.2). I have compiled final programs that are a few month old and ones which are new, all have the same issue, so I think it has nothing to do with Xcode but with the El Capitan Mac OS.
When setting the SKView into the "Core Animation Layer", in Xcode "MainMenu.xib", dialog page "View Effects Inspector" and check all the SKViews to set into "Core Animation Layer", then everything is fine for small Animations. As soon as the 60 fps cannot reched, because I have too much objects in the scene, the View is only updated once a second and this looks horrible. With Yosemite, the Scene was updates 30 times a second, which is really enough for my purpose.
Because this does not depend on the Xcode version, it seems that Apple has changed something to "optimize" the screen redrawing and if it is not possible to make 60 fps, then the drawing is not made with 30 fps or whatever is possible, but only with 1 fps. I also tried "Can Draw Concurrently" on the "Attributes Inspector" page but this makes no difference at all. I use a new 8-core Mac Pro with D700 graphic. So this should not be the reason.
I also tried to limit the screen updates with myView.frameInterval = 30 from which I expected that only two updates per second are made. But this command seems to do absolutely nothing. The myView.allowsTransparency = ... produces an exception, regardless if true or false. myView.asynchronous = true makes the updates as smooth as in Yosemite. But it needs 30 seconds or so to pull down a menu (with a big node count, of course) and you cannot work with the program. This is - in the result - not identically to the "Can Draw Concurrently" option in Xcode.
Is it possible to change to the Yosemite rendering, because all described options seem to be not optimal.
Any ideas how to handle a large node-count or restrict the update-rate so that the program can be quit comfortably by menu?
I have now developed a workaround. With some additional lines of code I get the same results in Yosemite and in El Capitan. The Performance in El Capitan is about twice as quick than in Yosemite.
"SKView" must be set into the "Core Animation Layer" in "MainMenu.xib" or you will see no Sprite at all
You can define as much "SKViews" as you want. I will only show one as an example
The Definition of the Views in the AppDelegate Class needs some more code:
class AppDelegate: NSObject, NSApplicationDelegate
{
#IBOutlet var myWindow1: NSWindow!
#IBOutlet var mySKView1: SKView!
// other functions here as needed
func applicationDidFinishLaunching (aNotification: NSNotification)
{
let scene_size = CGSizeMake(1280.0, 800.0) // For example 1280x800 Pixel
let myScene1 = myScene1Class(size: scene_size)
mySKView1.scaleMode = .ResizeFill // works for me better than ".AspectFill"
mySKView1.ignoresSiblingOrder = false
mySKView1.asynchronous = true // This makes the difference in smooth Display-Speed
mySKView1.showsFPS = false
mySKView1.showsNodeCount = false
mySKView1.presentScene(myScene1)
mySKView1.paused = true // This makes the difference in Event-Handling
// Start your Main-Program-Process here
}
}
The "Can Draw Concurrently" Option in "MainMenu.xib" can be set or not, it makes no difference
Screen Updates start automatically when adding Sprites and showing the windows. When I present the scene in "AppDelegate", no sprite is in it. This is done by my automatic initialization for every program.
If you want, you can play with the two options "mySKView1.asynchronous = true" and "mySKView1.paused = true". If you set one to "false", you can see the problems. Note, that you must define much nodes to make this problem visible at all, because if your Mac reaches 60 fps because you have less nodes, than everything seems fine regardless which option you choose. And you will nedd two "SKViews" or more, in one or more Windows.
Tested with 130000 (130k!) nodes, making about 20 fps. Tested with 260000 (260k!) nodes, making about 10 fps. Three other "SKViews" defined with no sprites to test the whole thing.
I am building a project in OSX (Yosemite) with wxWidgets 3.0.2.
I can remove a blue border around the wxTextCtrl window by using wxBORDER_NONE. But when I put it in a sizer, it has a 3 pixel grey border that I just can't get rid of. What's the point of having 2 borders, one of which cannot be removed? Surely people want to customise more than that?
Is there any possible way to remove it? I don't really want to hack at the wx source, but I will if I have to.
Or is there another way of controlling layout without using sizers, than might cause the border not to appear?
Update: It seems to be the focus highlight border. I don't want it.
Is there any way of disabling the border around the focused UI object? It's so frustrating because it is such a minor thing, but my program is useless if can't remove it.
In case someone else stumbles into this post, this answer is for the updated question:
Update: It seems to be the focus highlight border. I don't want it.
Is there any way of disabling the border around the focused UI object?
Using wxWidgets APIs, NO, there is no way to remove it, since it's a behavior of the native NSTextField class. I was only able to remove it by editing the wx source itself to set the focusRingType property of the underlying NSTextField object to NSFocusRingTypeNone:
File: core/textctrl.mm
Func: wxWidgetImpl::CreateTextControl
NSTextField* v = nil;
if ( style & wxTE_PASSWORD )
v = [[wxNSSecureTextField alloc] initWithFrame:r];
else
v = [[wxNSTextField alloc] initWithFrame:r];
...
// remove glow/border when textfield gets focused
[v setFocusRingType:NSFocusRingTypeNone];
I've also set BORDER_NONE on my wxTextCtrl.
Of course, this sort of changes the standard OS X look-and-feel, so maybe that's why this wasn't exposed as a wxTextCtrl API? Or it breaks something else? But so far it's working OK on my end. Plus, my app needs to have its own custom theme that doesn't go well with the glow border.
I'm using wxWidgets 3.1.0 (cloned from their repo) and OS X 10.12.
This worked for me -on Windows-:
First --> bind the EVT_SET_FOCUS to a styling method.
Second --> reset the fg and bg colours to your original design.
Python code:
button_1.Bind(wx.EVT_SET_FOCUS, focus_without_border)
def focus_without_border(evt=None):
element = evt.GetEventObject()
element.SetForegroundColour( wx.Colour( 241, 241, 241 ) )
element.SetBackgroundColour( wx.Colour( 40, 41, 42 ) )
I have a simple desktop app where a TextField should be focused when the window loads. I have this working, but it's a little annoying that, having loaded the users content into the TextField, the entire contents of the field become selected automatically. The user may want to start editing the content, but they will rarely/never want to replace it all at once (imagine a text editor doing this, to see what I mean).
I see there is an Action for selectAll: but what I want is the opposite Action of selectNone:
I tried passing nil to the selectText method, but that doesn't work:
textField.selectText(nil)
I found a number of answers on StackOverflow that mention a selectedTextRange, but this appears to be outdated, because Xcode 6.3 doesn't recognize this as a valid property on TextField.
Can anyone explain how I do this?
It's been a while since I've dealt with NSTextFields to this level (I work mostly in iOS these days).
After doing a little digging I found this on the net:
NSText* textEditor = [window fieldEditor:YES forObject:textField];
NSRange range = {start, length};
[textEditor setSelectedRange:range];
window is the window containing your field, textField.
This requires the field editor to be managing your field, what can be done simply by previously selecting the whole text of the field using the selectText:sender method.
Here is the final swift code that I got working based on what Duncan C posted:
if let window = NSApplication.sharedApplication().mainWindow {
let textEditor = window.fieldEditor(true, forObject: textField)!
let range = NSRange(0..<0)
textEditor.selectedRange = range
}