Posts

Post not yet marked as solved
4 Replies
Dear friend, It works in iOS, but how to do it on Cocoa(macOS Application)? There is no UIApplication, and no open functions on NSApplication.shared. How to open safari in Cocoa application?
Post not yet marked as solved
4 Replies
Thanks a lot, you did me a great favor.
Post not yet marked as solved
1 Replies
I've found the reason caused the problem: As I set the WindowMask in WindowController. Thanks All.
Post marked as solved
11 Replies
To reproduce the problem, Add enough items to a tabView like this: var tabViewItem:NSTabViewItem=NSTabViewItemExtension.init()         tabViewItem.label="192.168.255.254"         var objects:NSArray?=nil         Bundle.main.loadNibNamed("OperationTab", owner: nil, topLevelObjects: &objects)         for object in objects!{             if object is NSView{                 tabViewItem.view=object as! NSView             }             if object is OperationTabViewController{                 tabViewItem.viewController=object as! OperationTabViewController             }         }         var vc=tabViewItem.viewController as! OperationTabViewController         vc.setServerName(serverName: "192.168.255.254")         mainTab.addTabViewItem(tabViewItem)         objects=nil         tabViewItem=NSTabViewItemExtension.init()         tabViewItem.label="192.168.255.253"         Bundle.main.loadNibNamed("OperationTab", owner: nil, topLevelObjects: &objects)         for object in objects!{             if object is NSView{                 tabViewItem.view=object as! NSView             }             if object is OperationTabViewController{                 tabViewItem.viewController=object as! OperationTabViewController             }         }         vc=tabViewItem.viewController as! OperationTabViewController         vc.setServerName(serverName: "192.168.255.253")         mainTab.addTabViewItem(tabViewItem) ... (need add enough items) Then do the function while click a 'Close' button: mainTab.removeTabViewItem(item)
Post marked as solved
11 Replies
    func removeTabView(operationView:NSView){         for item in mainTab.tabViewItems{             if item.view == operationView{                 mainTab.removeTabViewItem(item)                 break;             }         }         mainTab.setNeedsDisplay(mainTab.frame)         mainTab.display()         Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false) { (timer) in             OperationQueue.main.addOperation {[weak self]in                 print("displayIfNeeded()")                 self?.mainTab.displayIfNeeded()                 self?.mainTab.display()                 self?.view.displayIfNeeded()                 self?.view.display()                 self!.view.resizeSubviews(withOldSize: NSSize.init(width: self!.view.frame.width, height: self!.view.frame.height))                 self!.mainTab.resizeSubviews(withOldSize: NSSize.init(width: self!.mainTab.frame.width, height: self!.mainTab.frame.height))             }         }     } No effect, while the 'Close' button clicked, it will call the function removeTabView(), and the tabViewItem was removed, but the tabView's labels not completely redrawed.
Post marked as solved
11 Replies
Yes, I override the drawLabel function, and did the NSString.draw(inrect) to show the three points while the width of the item’s label is not enough. But the drawLabel function always only called twice while I do the removeTabViewItem one time in more than 10 tabviewItems.
Post marked as solved
11 Replies
The problem is occurring here: The func drawLabel(_ shouldTruncateLabel: Bool, in labelRect: NSRect) of NSTabViewItem only called twice if there are enough items that item labels has truncated. Is there any solution to redraw all labels of tabViewItems?
Post marked as solved
11 Replies
I have tried using: mainTab.displayIfNeeded() and mainTab.display() , but not effect.