区分iphone上的UI按钮
我用按键做键盘。此键盘上有49个UI按钮,用于创建以下内容:区分iphone上的UI按钮,iphone,uibutton,Iphone,Uibutton,我用按键做键盘。此键盘上有49个UI按钮,用于创建以下内容: - (void)viewDidLoad { [self emoticonButtonOnTheKeyBoard_xCoordinate:0 yCoordinate:0 Emoticone_name:@"emoticon_angel.gif" backString:@"O:-)" keyboardView:self.view]; [self emoticonButtonOnTheKeyBo
- (void)viewDidLoad {
[self emoticonButtonOnTheKeyBoard_xCoordinate:0 yCoordinate:0 Emoticone_name:@"emoticon_angel.gif" backString:@"O:-)" keyboardView:self.view];
[self emoticonButtonOnTheKeyBoard_xCoordinate:40 yCoordinate:0 Emoticone_name:@"emoticon_angry.gif" backString:@":-@" keyboardView:self.view];
[self emoticonButtonOnTheKeyBoard_xCoordinate:80 yCoordinate:0 Emoticone_name:@"emoticon_big_smile.gif" backString:@":-D" keyboardView:self.view];
[self emoticonButtonOnTheKeyBoard_xCoordinate:120 yCoordinate:0 Emoticone_name:@"emoticon_confused.gif" backString:@":-s" keyboardView:self.view];
[self emoticonButtonOnTheKeyBoard_xCoordinate:160 yCoordinate:0 Emoticone_name:@"emoticon_cool.gif" backString:@"B)" keyboardView:self.view];
[self emoticonButtonOnTheKeyBoard_xCoordinate:200 yCoordinate:0 Emoticone_name:@"emoticon_cry.gif" backString:@":,-(" keyboardView:self.view];
[self emoticonButtonOnTheKeyBoard_xCoordinate:240 yCoordinate:0 Emoticone_name:@"emoticon_disappoint.gif" backString:@":-|" keyboardView:self.view];
[self emoticonButtonOnTheKeyBoard_xCoordinate:280 yCoordinate:0 Emoticone_name:@"emoticon_emo.gif" backString:@"(Emo)" keyboardView:self.view];
}
以及创建方法:
- (IBAction) updatingTheTextFiledWithEmoticon
{
iPhoneClientDevAppDelegate *appDelegate = (iPhoneClientDevAppDelegate *)[[UIApplication sharedApplication] delegate];
[[appDelegate.personalchatviewcontrollerReference message_textfield] setText:[[[appDelegate.personalchatviewcontrollerReference message_textfield] text] stringByAppendingString:appDelegate.EmoticonCurrentButtonValue]];
}
- (void) emoticonButtonOnTheKeyBoard_xCoordinate:(int)x_coordinate yCoordinate:(int)y_coordinate Emoticone_name:(NSString *)emoticon_name
backString:(NSString *)stringback keyboardView:(UIView *)keyboard
{
iPhoneClientDevAppDelegate *appDelegate = (iPhoneClientDevAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.EmoticonCurrentButtonValue = stringback;
UIButton* emticon_button = [UIButton buttonWithType:UIButtonTypeCustom];
emticon_button.frame = CGRectMake(x_coordinate, y_coordinate, 40, 43);
[emticon_button setImage:[UIImage imageNamed:emoticon_name] forState:UIControlStateNormal];
[emticon_button setImage:[UIImage imageNamed:emoticon_name] forState:UIControlStateHighlighted];
[emticon_button setBackgroundImage:[UIImage imageNamed:@"background.png"] forState:UIControlStateNormal];
[emticon_button ]
[keyboard addSubview:emticon_button];
[emticon_button addTarget:nil action:@selector(updatingTheTextFiledWithEmoticon) forControlEvents:UIControlEventTouchUpInside];
}
所以,我成功地覆盖了键盘,但我有一个大问题。
当我按下键盘上的按钮时,应用程序总是返回上次创建的按钮值。
我怎样才能区分这些按钮
谢谢 给他们一个唯一的
.tag
属性(键入int),并确保选择器将发送者作为参数:
-(IBAction)buttonPressed:(id)theButton
{
NSLog("Button %d pressed",[theButton tag]);
}
给他们一个唯一的
.tag
属性(键入int),并确保选择器将发送者作为参数:
-(IBAction)buttonPressed:(id)theButton
{
NSLog("Button %d pressed",[theButton tag]);
}