nsview

The Autosizing property setting for NSView is missing

落爺英雄遲暮 提交于 2019-12-04 07:37:32
I ran into this really frustrating issue today. I want to set my view to be autosizing like this: But all I find in my xcode settings for an NSView is like this: The two screenshots are taken from two different projects with the same xcode 4.3.2. Is this a bug or am I missing something? Thanks. Yang Seaid's solution works. but i think it's bug because the auto sizing tool will apear about half a second when switching to another inspector. Xcode 4 interface-builder problems Starting in Xcode 4.3 the xib files for Cocoa projects have auto layout turned on initially. When a xib file uses auto

Why is my Cocoa NSWindow taking such a long time to become active?

℡╲_俬逩灬. 提交于 2019-12-04 06:10:36
问题 My app starts and the window shows (all controls are physically there) in an inactive-like state (controls grayed out and inactive to keys/mouse). It takes three to five seconds for the window to become active? Same pattern occurs when I switch back to this app from another. EDIT I have added logging in various Window, Delegate & Controller methods to determine where precisely the slowdown is occurring and all of these run before the slowdown: 1. 2015-02-08 15:22:16.032 Grid[40199:5354843]

How to block NSView events under another NSView?

半腔热情 提交于 2019-12-04 05:44:17
Here is the idea: I have a NSWindow containing 2 NSView, let's call them ViewA and ViewB. ViewA has a list of subview objects, each object has its own tracking area set and handles a mouseDown event. ViewB is a hidden view, which appears above ViewA. The problem is when ViewB appears, ViewA still receives mouseDown events. So when I click on ViewB, the object behind the ViewB receives the mouseDown event. I would like to know if there's any way to block the events of ViewA while ViewB is over it. I know I can remove the tracking area from every object, but it still responds to the mouseDown

NSView initialization: -init: vs. -awakeFromNib:

折月煮酒 提交于 2019-12-04 04:53:39
I have a simple class MyView inherited from NSView and instance variable NSImage * image; in it. Class functionality is to draw image on the view. However, in -drawRect: image instance always equal nil , if it was initialized in -init: function and not nil if it was initialized in -awakeFromNib: . Log shows both -init: and -awakeFromNib: functions are called only once. Does -awakeFromNib: reinitialize GUI component by default? No. There is no default implementation for awakeFromNib . Your problem is that you're overriding the wrong initialization method. An NSView 's designated initializer is

Rounded corners on NSTableView

回眸只為那壹抹淺笑 提交于 2019-12-04 02:04:17
问题 I have a custom view subclass similar to NSBox that draws a rounded box background. The problem is that if I place a view like an NSTableView in the box view, it does not clip to the rounded corners. Is there any way to round the corners of NSTableView and its parent scroll view? 回答1: I haven't tried this with a table view but have with other controls. In a subclass of NSTableView (or whatever view/control you want to clip) Override drawRect: Create an NSBezierPath with the shape you want

Adding a custom view to toolbar

…衆ロ難τιáo~ 提交于 2019-12-03 16:29:17
问题 I'm struggling with Cocoa for 2 hours now without success. I want to add a custom view to the toolbar. So, I added a NSToolbar to the window (with IB), and added my view (which works perfectly). IB automatically created a NSToolbarItem. I followed the instructions from Apple here: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Toolbars/Tasks/AddRemoveToolbarItems.html#//apple_ref/doc/uid/20000755-BBCGJCDJ The problem is that I don't know what to do now, the view doesn

NSWindow launching with wrong size after setting contentViewController to NSTabViewController

爱⌒轻易说出口 提交于 2019-12-03 16:20:12
I have an Xcode project with an NSWindowController whose contentViewController was set to a subclass of NSViewController . I recently removed the NSViewController subclass from the storyboard and replaced the contentViewController with an NSTabViewController subclass. Now, when I run the application, the NSWindow opens with a size of 500x500 instead of the size of the first tab. What's more, there is no view I can see in the storyboard that has a size of 500x500, and that size isn't being programmatically, either. The window itself is set to a different size, as is the view in the

Force NSView to redraw programmatically

落花浮王杯 提交于 2019-12-03 14:22:45
My app has two different states, and every state will be representing with a NSView. so there is only one view showed at a time, the problem is when I switched between the views the app doesn't show the new state until I resize the window manually! I searched about this problem and come with more than one solution but nothing worked with me: [myView setNeedsDisplay:YES]; [myView display]; [[myView.window contentView] setNeedsDisplay:YES]; [mySubView1 setHidden:YES]; || [mySubView1 removeFromSuperView]; I even defined myView as Outlet, and nothing work. and this is my code if (appState == 1) {

Adding an NSProgressIndicator to the dock icon

徘徊边缘 提交于 2019-12-03 12:51:07
I'm creating an application which should show a progress bar in the dock icon. Currently I have this, but it's not working: NSProgressIndicator *progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, 10.0f, 20.0f)]; [progressIndicator setStyle:NSProgressIndicatorBarStyle]; [progressIndicator setIndeterminate:NO]; [[[[NSApplication sharedApplication] dockTile] contentView] addSubview:progressIndicator]; [progressIndicator release]; Or must I draw it on the dock myself? Can anyone help me? Thanks. In the finish I had to use the following code as the contentView was

How to make NSView not clip its bounding area?

喜你入骨 提交于 2019-12-03 12:36:59
问题 I created an empty Cocoa app on Xcode for OS X, and added: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.view = [[NSView alloc] initWithFrame:NSMakeRect(100, 100, 200, 200)]; self.view.wantsLayer = YES; self.view.layer = [CALayer layer]; self.view.layer.backgroundColor = [[NSColor yellowColor] CGColor]; self.view.layer.anchorPoint = CGPointMake(0.5, 0.5); self.view.layer.transform = CATransform3DMakeRotation(30 * M_PI / 180, 1, 1, 1); [self.window.contentView