我在一个带有文本"__DRAG_AND_DROP_YOUR_MEDIA_HERE"的视图中以IB为中心的NSTextField(标签).在我的控制器中使用NSLocalizedString来翻译文本:
English.lproj/Localizable.strings:
"__DRAG_AND_DROP_YOUR_MEDIA_HERE" = "Drag & Drop your media here"
Run Code Online (Sandbox Code Playgroud)
French.lproj/Localizable.strings:
"__DRAG_AND_DROP_YOUR_MEDIA_HERE" = "Déposer vos média ici"
Run Code Online (Sandbox Code Playgroud)
只有初始文本"__DRAG_AND_DROP_YOUR_MEDIA_HERE"在视图中居中.翻译后的文本不是中心(取决于长度).所有翻译的文本都以与原始文本相同的横坐标开始.我该如何解决这个问题?
PS:我不想玩setFrame,高度,宽度只是为了这样一个简单的点.我想还有另一种方法可以做到这一点.
谢谢.
我在专用服务器上遇到yum命令的问题(由OVH托管):
[root@mail-server ~]# yum clean all
[root@mail-server ~]# yum update
Modules complémentaires chargés : fastestmirror
One of the configured repositories failed (Inconnu),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This …Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中使用NSLocalizedString,但它总是失败.我做的是:
然后我使用NSLocalizedStrings如下,但它不起作用!
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSString *v1 = NSLocalizedString(@"MyWindow", nil);
//NSString *v1 = [[NSBundle mainBundle] localizedStringForKey:(@"MyWindow") value:@"" table:nil];
[label setStringValue:v1];
}
Run Code Online (Sandbox Code Playgroud)
在我的3 .strings文件中,我定义了下面的键/值:"MyWindow"="Ma Fenetre";
通常,我的标签应显示"Ma Fenetre"而不是"MyWindows"您可以在此处下载示例项目并告诉我问题在哪里.
Bellow我的应用包中的Resources文件夹的内容:
DerivedData om$ find test/Build/Products/Debug/test.app/Contents/Resources/
test/Build/Products/Debug/test.app/Contents/Resources/
test/Build/Products/Debug/test.app/Contents/Resources//de.lproj
test/Build/Products/Debug/test.app/Contents/Resources//de.lproj/File.strings
test/Build/Products/Debug/test.app/Contents/Resources//en.lproj
test/Build/Products/Debug/test.app/Contents/Resources//en.lproj/File.strings
test/Build/Products/Debug/test.app/Contents/Resources//fr.lproj
test/Build/Products/Debug/test.app/Contents/Resources//fr.lproj/File.strings
test/Build/Products/Debug/test.app/Contents/Resources//MainMenu.nib
Run Code Online (Sandbox Code Playgroud)
谢谢Elfoiros
我以编程方式在我的NSCollectionView中选择一个项目.项目按预期选择,但视图不会自动滚动到此项目.
[collectionView setSelectionIndexes:[NSIndexSet indexSetWithIndex:compt]];
Run Code Online (Sandbox Code Playgroud)
如何滚动到所选项目?
我使用NSTextfield的自己的类OMNTextfield子类来显示文本,并在文本长度大于控件宽度时为文本设置动画.
该文字在iTunes中像歌曲标题一样动画.它就像一个魅力!
现在我想更改文本的颜色和文本对齐方式.我已经搜索了一会儿setTextcolor,setAlignment,viewWillDraw,cellClass,...但没有任何工作=>我的文字仍然是黑色的!
我的问题:如何更改NSTextfield子类中的文本颜色/对齐方式?
Acoording 这个职位代码波纹管应该工作,但它不会!
-(void)viewWillDraw { // or whatever is the Appkit equivalent
[super setTextColor:[NSColor redColor]];
}
Run Code Online (Sandbox Code Playgroud)
完整代码:
//
// OMNTextField.h
#import <Cocoa/Cocoa.h>
@interface OMNTextField : NSTextField {
NSTimer * scroller;
NSPoint point;
NSString * text;
NSTimeInterval speed;
CGFloat stringWidth;
}
- (void) setText:(NSString *)newText;
@property (nonatomic, copy) NSString * text;
@property (nonatomic) NSTimeInterval speed;
@end
//
// OMNTextField.m
#import "OMNTextField.h"
@implementation OMNTextField
@synthesize text;
@synthesize speed;
- (void) dealloc {
[text release];
[scroller invalidate];
[super …Run Code Online (Sandbox Code Playgroud) objective-c ×4
cocoa ×3
nstextfield ×2
xcode ×2
centos ×1
cocoa-touch ×1
dns ×1
ios ×1
localization ×1
nsscrollview ×1
yum ×1