我以编程方式创建一个按钮..........
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(aMethod:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[view addSubview:button];
Run Code Online (Sandbox Code Playgroud)
如何更改标题颜色?
我创建了一个按钮,并为其添加了一个动作,但是一旦调用它,我就收到了这个错误:
-[NSCFDictionary numberButtonClick:]: unrecognized selector sent to instance
0x3d03ac0 2010-03-16 22:23:58.811
Money[8056:207] *** Terminating app
due to uncaught exception
'NSInvalidArgumentException', reason:'*** -[NSCFDictionary numberButtonClick:]: unrecognized selector sent to instance 0x3d03ac0'
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
UIButton *numberButton = [UIButton buttonWithType:UIButtonTypeCustom];
numberButton.frame = CGRectMake(10, 435, 46, 38);
[numberButton setImage:[UIImage imageNamed:@"one.png"] forState:UIControlStateNormal];
[numberButton addTarget:self action:@selector(numberButtonClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview: numberButton];
}
return self;
}
-(IBAction)numberButtonClick:(id)sender{
NSLog(@"---");
}
Run Code Online (Sandbox Code Playgroud) 我想更改UILabel文本颜色,但我无法更改颜色,这就是我的代码的样子.
UILabel *categoryTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 46, 16)];
categoryTitle.text = @"abc";
categoryTitle.backgroundColor = [UIColor clearColor];
categoryTitle.font = [UIFont systemFontOfSize:12];
categoryTitle.textAlignment = UITextAlignmentCenter;
categoryTitle.adjustsFontSizeToFitWidth = YES;
categoryTitle.textColor = [UIColor colorWithRed:188 green:149 blue:88 alpha:1.0];
[self.view addSubview:categoryTitle];
[categoryTitle release];
Run Code Online (Sandbox Code Playgroud)
标签文本颜色为白色,而不是我的自定义颜色.
感谢您的帮助.
如何确定角色是否是使用红宝石的中文角色?
当我打开 xocde 时,它会弹出一个窗口,并告诉我:
"xcode scanning for plug-ins failed.
You may not have appropriate permission to read or load installed plug-ins."
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么办 ?
我想通过点击关闭按钮解除键盘,如何在键盘上建立一个栏?像这样: alt text http://www.alexcurylo.com/blog/wp-content/uploads/2009/10/UIKeyboardDismiss.png
我想制作一个电子书阅读器iPhone应用程序.我应该使用UITextView
还是UIWebView
显示文字?其他电子书阅读器使用哪种控件?
在rails应用程序中,我有一个返回json字符串的操作.它看起来像这样:
if exist_user
format.json { render json: {:msg => 'has this user'}}
else
Run Code Online (Sandbox Code Playgroud)
但是rails显示错误:参数太少
如何渲染自定义json字符串?