我正在开发一个简单的计时器应用程序,我已经创建了一个带菜单的NSStatusItem,我有一些NSTextField标签可以更新计时器标签(http://cld.ly/e81dqm),但是当我点击状态项时NSTimer停止(并停止更新标签).....我怎样才能解决这个问题?
编辑:这是启动计时器的代码:
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerDidUpdate:) userInfo:nil repeats:YES];
当它被更改时,我如何收到NSDatePicker值的通知?
我有一个NSArrayController
和我当我得到selectedObjects
并创建一个NSString,其值valueForKey:@"Name"
返回
(
"This is still a work in progress "
)
Run Code Online (Sandbox Code Playgroud)
而我想要的只是文字中""
我将如何得到它?这也是我的代码:
NSArray *arrayWithSelectedObjects = [[NSArray alloc] initWithArray:[arrayController selectedObjects]];
NSString *nameFromArray = [NSString stringWithFormat:@"%@", [arrayWithSelectedObjects valueForKey:@"Name"]];
NSLog(@"%@", nameFromArray);
Run Code Online (Sandbox Code Playgroud)
编辑:我在数组中也有其他字符串
当用户双击表格视图行时,我希望有一个详细视图进入焦点.我如何在代码中更改窗口的视图?
我有一个自定义按钮: 我的按钮http://cld.ly/29ubq
我需要将文本置于中心,这是我的代码:
NSMutableParagraphStyle *style =
[[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[style setLineBreakMode:NSLineBreakByWordWrapping];
[style setAlignment:NSLeftTextAlignment];
att = [[NSDictionary alloc] initWithObjectsAndKeys:
style, NSParagraphStyleAttributeName,
[NSColor blackColor],
NSForegroundColorAttributeName, nil];
[style release];
// other Drawing code here
[[self title] drawInRect:[self bounds] withAttributes:att];
Run Code Online (Sandbox Code Playgroud)
如何将文本置于按钮中心(不是边界的中心)?
我正在使用MGTwitterEngine连接到twitter,我想将OAuth与MGTwitterEngine一起使用?
我想改变我画的按钮的填充(我将NSButton子类化)
这是我已经得到的代码:
- (void)drawRect:(NSRect)dirtyRect {
// Drawing code here.
// Create the Gradient
NSGradient *fillGradient = [[NSGradient alloc] initWithStartingColor:[NSColor lightGrayColor] endingColor:[NSColor darkGrayColor]];
// Create the path
aPath = [NSBezierPath bezierPath];
[aPath moveToPoint:NSMakePoint(10.0, 0.0)];
[aPath lineToPoint:NSMakePoint(85.0, 0.0)];
[aPath lineToPoint:NSMakePoint(85.0, 20.0)];
[aPath lineToPoint:NSMakePoint(10.0, 20.0)];
[aPath lineToPoint:NSMakePoint(0.0, 10.0)];
[aPath lineToPoint:NSMakePoint(10.0, 0.0)];
[fillGradient drawInBezierPath:aPath angle:90.0];
[fillGradient release];
}
- (void)mouseDown:(NSEvent *)theEvent {
NSGradient *fillGradient = [[NSGradient alloc] initWithStartingColor:[NSColor lightGrayColor] endingColor:[NSColor darkGrayColor]];
[fillGradient drawInBezierPath:aPath angle:-90.0];
}
Run Code Online (Sandbox Code Playgroud)
我收到一个EXC_BAD_ACCESS
信号 我该怎么做?
如何删除所选的NSTableView行及其相应的Core Data条目?
我已经开始使用NSViewControllers,我不能在我的生活中弄清楚如何通过NSViewController将内容从CoreData实体获取到TableView(例如)?
cocoa ×12
objective-c ×10
core-data ×3
drawing ×2
nstableview ×2
nsarray ×1
nsdatepicker ×1
nstimer ×1
nsview ×1
nswindow ×1
oauth ×1
rgb ×1
scrollbars ×1
twitter ×1