cocoa

Line spacing and paragraph alignment in CoreText

六月ゝ 毕业季﹏ 提交于 2020-01-21 03:35:08
问题 I am using CoreText to render multiple columns of text. However, when I set the first letter of the 1st paragraph to a bold, larger font than the rest of the text, I incur 2 issues (both visible in the attached image): The spacing underneath the first line is too big (I understand that this is because the 1st character could be a g,y,p,q etc. Lines below the first line now do not line up with corresponding lines in the next column. Any advice on how to overcome these 2 issues would be greatly

Show NSSegmentedControl menu when segment clicked, despite having set action

坚强是说给别人听的谎言 提交于 2020-01-21 03:19:28
问题 I have an NSSegmentedControl on my UI with 4 buttons. The control is connected to a method that will call different methods depending on which segment is clicked: - (IBAction)performActionFromClick:(id)sender { NSInteger selectedSegment = [sender selectedSegment]; NSInteger clickedSegmentTag = [[sender cell] tagForSegment:selectedSegment]; switch (clickedSegmentTag) { case 0: [self showNewEventWindow:nil]; break; case 1: [self showNewTaskWindow:nil]; break; case 2: [self toggleTaskSplitView

Why is raising an NSException not bringing down my application?

元气小坏坏 提交于 2020-01-20 22:06:31
问题 The Problem I'm writing a Cocoa application and I want to raise exceptions that will crash the application noisily. I have the following lines in my application delegate: [NSException raise:NSInternalInconsistencyException format:@"This should crash the application."]; abort(); The problem is, they don't bring down the application - the message is just logged to the console and the app carries on it's merry way. As I understand it, the whole point of exceptions is that they're fired under

How do I make an NSView move to the front of all NSViews

♀尐吖头ヾ 提交于 2020-01-20 17:13:31
问题 I have a super view, which has 2 subviews. These subviews are overlapped. Whenever i choose a view from a menu, corresponding view should become the front view and handle actions. i.e., it should be the front most subview. acceptsFirstResponder resigns all work fine. But the mouse down events are sent to the topmost sub view which was set. Regards, Dhana 回答1: Here's another way to accomplish this that's a bit more clear and succinct: [viewToBeMadeForemost removeFromSuperview]; [self

How do I make an NSView move to the front of all NSViews

蓝咒 提交于 2020-01-20 17:09:12
问题 I have a super view, which has 2 subviews. These subviews are overlapped. Whenever i choose a view from a menu, corresponding view should become the front view and handle actions. i.e., it should be the front most subview. acceptsFirstResponder resigns all work fine. But the mouse down events are sent to the topmost sub view which was set. Regards, Dhana 回答1: Here's another way to accomplish this that's a bit more clear and succinct: [viewToBeMadeForemost removeFromSuperview]; [self

Premature line wrapping in NSTextView when tabs are used

萝らか妹 提交于 2020-01-20 08:44:05
问题 I have a strange problem with NSTextView linewrapping after the 51st column if I enter a line of tabs. This only happens with tabs, not with any other character, which wrap correctly at the edge of the text view, not after the 51st character. This is easy to repeat. Create a blank project in XCode with a single window and just one NSTextView. The only non-default settings are that I have removed constraints, and used the old style autosize to autosize the textview so that it fills the window.

Programmatically changing desktop image

孤街浪徒 提交于 2020-01-20 03:49:05
问题 I am trying to change the desktop image; the procedure I've come up with is below. The first time this code is run, the resized image is displayed on screen as wallpaper, but the next time there is no reaction. What am I doing wrong? -(IBAction)click:(id)sender { NSData *sourceData; NSError *error; NSFileManager *filemgr; filemgr = [NSFileManager defaultManager]; screenArray = [NSScreen screens]; screenCount = [screenArray count]; unsigned index = 0; for (index; index < screenCount; index++)

Programmatically changing desktop image

扶醉桌前 提交于 2020-01-20 03:48:32
问题 I am trying to change the desktop image; the procedure I've come up with is below. The first time this code is run, the resized image is displayed on screen as wallpaper, but the next time there is no reaction. What am I doing wrong? -(IBAction)click:(id)sender { NSData *sourceData; NSError *error; NSFileManager *filemgr; filemgr = [NSFileManager defaultManager]; screenArray = [NSScreen screens]; screenCount = [screenArray count]; unsigned index = 0; for (index; index < screenCount; index++)

How to get an array of sentences using CFStringTokenizer?

落爺英雄遲暮 提交于 2020-01-20 02:44:35
问题 I've created an string tokenizer like this: stringTokenizer = CFStringTokenizerCreate( NULL , (CFStringRef)str , CFRangeMake(0, [str length]) , kCFStringTokenizerUnitSentence , userLocale); But how do I obtain those sentences now from the tokenizer? The CF String Programming Guide doesn't mention CFStringTokenizer or tokens (did a full-text search in the PDF). 回答1: Here is an example of CFStringTokenizer usage: CFStringRef string; // Get string from somewhere CFLocaleRef locale =

NSNotificationCenter: Why bother calling removeObserver?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-20 02:15:21
问题 The gods have parachuted many habits into my isolated jungle village, such as: - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; } Their ways are strange to me, yet I still seek to understand them. Why bother cleaning loose ends up if the instance is going away? Will the reference/retain count to that instance not be decremented? Will it clutter some sort of Notification Hash Table lurking out there that holds a list of all the listeners? 回答1: