有没有办法在NSButtons或其他可可界面元素中绘制像图像的NSImage?
以下是示例:

Apple使用带有黑色图标的pdf:

总是当我尝试在NSDictionary中将整数设置为Object时,程序在没有消息的情况下崩溃(控制台中没有任何内容).这段代码有什么问题?:
NSString *string = @"foo";
int number = 1;
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
string, @"bla1", number, @"bla2",nil];
Run Code Online (Sandbox Code Playgroud) 我想改变NSWindow标题栏的高度.
这里有些例子:

和…

我可以使用NSToolbar,但问题是我无法将视图放置得非常高(例如:我不能将segmentedControl放在比图片更高的位置,因为还有标题栏)

如果我删除标题栏,我无法放置NSToolbar,窗口不可移动.
你有什么想法吗?
我想,当(例如)用户打开iTunes时,我的应用程序会打开.我怎样才能做到这一点?
我试图向viewDidLoad和viewDidAppear添加动画,但它不起作用:
- (void)viewDidAppear:(BOOL)animated{
[UIView beginAnimations:@"transition" context:NULL];
[UIView setAnimationTransition:110 forView:self.view cache:YES];
[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)
为什么?
我目前正在开发一个iPhone项目.我想在Objective-C中动态扩展UILabel,如下所示:
替代文字http://img268.imageshack.us/img268/9683/bildschirmfoto20100323u.png
这怎么可能?我认为我必须使用CoreAnimation,但我没有工作.这是我试过的代码:
UILabel * fooL = //[…]
fooL.frame = CGRectMake(fooL.frame.origin.x, fooL.frame.origin.y, fooL.frame.size.width, fooL.frame.size.height);
fooL.font = [UIFont fontWithName:@"Helvetica" size:80];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
fooL.font = [UIFont fontWithName:@"Helvetica" size:144]; //bigger size
fooL.frame = CGRectMake(20 , 44, 728, 167); //bigger frame
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
此代码的问题在于它不会动态更改fontsize.
我用xcode中的窗口模板创建了一个通用应用程序.现在我想提交我的应用程序的iPad版本,因为iPhone版本还没有完全编程.
这怎么可能?我需要改变什么?(目标设置,info.plist等?)
我想获得NSNumber的unsigned long值.我不知道为什么,但它不起作用.这是我做的:
NSString * stern = [idd objectAtIndex:indexPath.row]; // get a String with Number from a NSArray
NSNumberFormatter * lols = [[NSNumberFormatter alloc] init];
NSNumber * iddd = [lols numberFromString:stern];
NSLog(@"%@", iddd); // I get the right number: 8084143463
unsigned long fooo = [iddd unsignedLongValue];
NSLog(@"%lu", fooo); // I get the wrong number: 3789176167
[twitterEngine deleteUpdate:fooo];
Run Code Online (Sandbox Code Playgroud) 总是当我尝试使用Int = arc4random%MAXNUM生成随机数时,该数字的长度与MAXNUM数字长度-1一样长.因此,如果我设置arc4random%1000000,则该数字介于100000-999999之间.如何获得78,476或4842等不同的数字?这是一个样本:
int number = arc4random() % 1000000;
outputLabel.text = [NSString stringWithFormat:@"The Number is %d", number];
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助,抱歉我的英语不好!
更新:好的,我刚看到,我不会只获得5位数字,但大部分时间.有没有办法通过较少的数字获得更低数字或数字?
您好我在xcode中得到"Lvalue required as assignment operand of assignment"错误.为什么?这是我的代码(window1/2是UIViewController):
- (void)loadView
{
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,460)];
UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0,0,640,460)];
self.window1 = [TweetViewController alloc];
self.window2 = [InfoViewController alloc];
[contentView addSubview:self.window1.view];
self.window2.view.frame.origin.x = 320; //HERE IS THE ERROR!!
[contentView addSubview:self.window2.view];
[scrollView addSubview:contentView];
scrollView.contentSize = contentView.frame.size;
scrollView.pagingEnabled = YES;
self.view = scrollView;
[contentView release];
[scrollView release];
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
objective-c ×6
cocoa ×4
iphone ×4
xcode ×4
macos ×2
draw ×1
integer ×1
ipad ×1
launch ×1
nsdictionary ×1
nsimage ×1
nswindow ×1
properties ×1
submission ×1
uilabel ×1
uiview ×1
viewdidload ×1