小编jam*_*mil的帖子

如何一次删除多个UIButton的背景图像?

我在我的应用程序中使用了20个UIButton.我在click事件中设置了所有这些UIButton的背景图像.所有这些UIButton都保存在NSMutableArray中.这是代码.

             saveBtn = [[NSMutableArray alloc] init];
             for (int i=0; i<20; i++) {
             UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
             btn.frame = CGRectMake(spacex, spacey, 30.0, 30.0);
             idx = arc4random()%[arr count];
             NSString* titre1 = [arr objectAtIndex:idx];
             [btn setTitle:titre1 forState:UIControlStateNormal];   
             spacex = spacex + 30;
             [saveBtn addObject:btn];
             [self.view addSubview:btn];
          }
Run Code Online (Sandbox Code Playgroud)

我在这里成功是我的代码.

 UIButton *currentButton = (UIButton *)sender;
 UIImage * imgNormal = [UIImage imageNamed:@"subtabButton.png"];
 [currentButton setBackgroundImage:imgNormal forState:UIControlStateNormal];
 [currentButton setTitle:currentButton.titleLabel.text forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)

但是在这20个UIButton之间有3个UIButton,我希望当玩家点击这三个UIButton中的一个时,所有之前设置的背景图像都会从UIButtons中移除.任何人都可以指导我们如何做到这一点.提前做好准备.

iphone objective-c background-image uibutton ios

1
推荐指数
1
解决办法
1221
查看次数

如何在UITextview上的点击事件中停止keyBoard外观?

在我的iPad应用程序,我使用的TextView只对由于其滚动属性,而不是使用的UILabel文本Displaying.As我需要为什么我使用的UITextView来那显示较大的文本.在我的应用程序中,我不需要在UITextview中编辑文本,但问题是,当我点击Textview滚动键盘时,它隐藏了我的textview,所以我希望我的键盘永远不会出现在click事件上.我进行搜索但是没有找到任何合适的解决方案.任何帮助都将得到适用.谢谢

keyboard xcode uitextview ipad ios

1
推荐指数
1
解决办法
4502
查看次数

如何在UITableview的CustomCell中单击UITextField时向上移动查看?

我在UITableview的自定义单元格中有TextField.我的Tableview是MainView的下半部分所以当我在CustomCell键盘上单击TextField时出现哪个HIde我的textfield.My下面的图像显示我的问题

在此输入图像描述

在这里我有一个代码,当我在MainView.please中有UITextField时,编辑下面的代码,因为我想要整个视图动画,当我点击UITextfield.

-(void)textFieldDidBeginEditing:(UITextField *)textField {

if (textField.tag > 0) {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationBeginsFromCurrentState:YES];
    self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y-165.0,
                                 self.view.frame.size.width, self.view.frame.size.height);
    [UIView commitAnimations];
}   

   }
 -(void)textresign{

[[self.view viewWithTag:1]resignFirstResponder];
   }
-(void)textFieldDidEndEditing:(UITextField *)textField {         
if (textField.tag > 0) {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationBeginsFromCurrentState:YES];
    self.view .frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y+165.0,
                                  self.view.frame.size.width, self.view.frame.size.height);
    [UIView commitAnimations];
}   

  }
Run Code Online (Sandbox Code Playgroud)

但我不知道如何修复它为我的自定义单元格UITextField.Any帮助将被适用.

iphone keyboard xcode uitextfield uiviewanimation

1
推荐指数
1
解决办法
2896
查看次数

以编程方式将某些文本分配给UITextView中的特定行

我以编程方式创建UITextView的实例.我想以编程方式在UITextView中为特定行分配一些文本.这是我创建UITextView的代码.

UITextView *textView =[[UITextView alloc]init];
textView.frame=CGRectMake(0,0,282,210);
[textView setReturnKeyType:UIReturnKeyDone];
[self.view addSubview:textView];
Run Code Online (Sandbox Code Playgroud)

例如,我想在特定行添加一些文本(在第5行的末尾).

以编程方式,如何做到这一点?

iphone xcode objective-c uitextview ios

0
推荐指数
1
解决办法
1705
查看次数