我正在尝试从 UITapGestureRecognizer 中拖动 IBAction,该 IBAction 放置在位于自定义表格视图单元格中的 UIImageView 上。
但是,它不允许我将动作从故事板拖动到自定义表格视图单元格的子类
单元的类已正确设置为身份检查器中的正确文件。并且在图像视图上启用用户交互。
所以我尝试输入 IBAction 并将其从文件连接到故事板,它给出了以下错误:
这很令人困惑,因为我能够从 UIButtons 和其他视图对象中拖动 IBActions;只是不是这个 UITapGestureRecognizer。我最近将 Xcode 更新到 7.2.1
这是我的文档大纲中的视图层次结构:
这是点击手势的连接:
以及图像视图的连接:
当用户更新 UIDatePicker(倒数计时器)时,我试图更新标签。但是,它仅在第一次旋转后更新它。第一次旋转不会改变标签值。我试图在主队列上执行 UI 更新但无济于事。
我有一个内部有一些简单代码的IBAction:
-(IBAction)change:(id)sender {
[textfield setHidden:NO];
[self dolengthyaction];
}
Run Code Online (Sandbox Code Playgroud)
'textfield'是nib文件中的NSTextField,-'dolengthyaction'是一个大约需要一分钟才能完成执行的函数.
我的问题是:为什么在"dolengthyaction"执行完之后才显示文本字段?我希望在dolengthyaction开始之前揭示它.这是一个固有的问题还是我的代码有问题?(或在我的代码的另一部分?)
我仍然不擅长编程,所以如果我措辞严厉并且格式错误,我会道歉.
编辑:除了这个IBAction和-dolengthyaction之外别无其他......
-(void)doLengthyAction {
sleep(10);
}
-(IBAction)change:(id)sender {
[textfield setHidden:NO];
[self doLengthyAction];
[textfield setHidden:YES];
}
Run Code Online (Sandbox Code Playgroud)
我真正想做的就是在动作运行时显示标签,并在动作完成后隐藏它.
基本上这意味着它现在还没有显示出来.
实际上,在-doLengthyAction中它不是睡眠(10)而是一个复制大约50 Mb材料的NSFileManager操作.代码相当长,但如果你想让我发布它我可以.我用sleep()测试了它,但它也不起作用.
他们在哪里说IBAction是什么,但不解释整个声明的含义.
什么是发件人和身份证?
此致,Namratha
我已经尝试了所有我在SO上找到的答案,所以要么我有不同的问题,要么热量进入我的大脑.
无论如何,我在故事板上有一个UIButton,它链接到一个名为_cameraButtonPress的IBAction(UIButton被称为_cameraButton).当按下按钮时我想禁用按钮一段时间,所以我立即调用[sender setEnabled:NO]; 这很好用.但是,在保存图像的不同功能中,成功保存后我使用[_cameraButton.setEnabled:YES]; 这不起作用.
如果我在IBAction调用的函数中用_cameraButton替换sender,这也不起作用.我把UIButton链接到IBOutlet.
我可以发布代码,但现在这是一个非常大的项目,以下是相关内容:
在标题中......
IBOutlet UIButton *_cameraButton;
Run Code Online (Sandbox Code Playgroud)
IBAction ......
- (IBAction) _cameraButtonPress:(id)sender {
[sender setEnabled:NO]; //stops button responding to touch events
Run Code Online (Sandbox Code Playgroud)
进一步降低功能:
} else {
NSLog(@"colour image saved successfully");
[_cameraButton setEnabled:YES];
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢.
我正在以编程方式访问IBAction并希望通过此IBAction调用传递两个参数.任何人都可以轻松推荐......
我有2个不同的按钮,可以在一个mapview中触发一组不同的注释.我有一些淡出按钮的动作方法,在这一点上应该出现一个注释,但是我无法弄清楚如何在注释方法中说"如果激活了这个动作,那么从这个类加载注释".所以这是我目前的代码
- (void)queryForAllPostsNearLocation:(CLLocation *)currentLocation withNearbyDistance:(CLLocationAccuracy)nearbyDistance {
if (????? IBAction 1 is activated ?????) {
NSString *button1 = @"Today";
}
if (????? IBAction 2 is activated ?????) {
NSString *button1 = @"Tomorrow";
}
PFQuery *query = [PFQuery queryWithClassName:button1];
Run Code Online (Sandbox Code Playgroud)
我希望我能正确地传达我的问题,有人可以帮助我.
你好我对电话号码的按钮动作,但是当我使用它时不打电话,什么都没有显示.
我的代码如下.
@IBAction func callPhone(sender: AnyObject) {
UIApplication.shared().canOpenURL((NSURL(string: "tel://1234567890")! as URL))
}
Run Code Online (Sandbox Code Playgroud)
谢谢 !
我创建了一个名为RegistrationButton的自定义UIButton.我目前正在尝试允许用户在三个按钮之间进行选择.选择按钮后,背景颜色和文本将发生变化.以下是IBAction的外观:
@IBAction func didTapBUtton(_ sender: UIButton) {
switch sender {
case studentButton:
studentButton.selected()
professionalButton.notSelected()
entrepreneurhsip.notSelected()
break
case professionalButton:
studentButton.notSelected()
professionalButton.selected()
entrepreneurhsip.notSelected()
break
case entrepreneurhsipButton:
studentButton.notSelected()
professionalButton.notSelected()
entrepreneurhsip.selected()
break
default:
break
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的自定义UIButton类的方法:
import UIKit
class RegistrationButton: UIButton {
override func awakeFromNib() {
super.awakeFromNib()
addBorder()
}
required init(coder:NSCoder) {
super.init(coder:coder)!
}
func addBorder(){
self.layer.borderColor = UIColor.white.cgColor
self.layer.borderWidth = 1
}
func selected(){
self.backgroundColor = .white
self.setTitleColor(UIColor(red:67,green:204,blue:144,alpha:1), for: .normal)
}
func notSelected(){
self.backgroundColor = UIColor(red:67,green:204,blue:144,alpha:1)
self.setTitleColor(UIColor.white, for: .normal)
}
Run Code Online (Sandbox Code Playgroud)
}
我目前有一个函数从数据库收集时间并返回它以供其他函数使用.它需要一个参数,该参数存储在应用程序的另一部分中,以便从数据库中收集值.
当我想在IBAction函数中调用此函数时,我的问题出现了.
这是我的函数代码:
func getDBValue(place: GMSPlace) -> Int {
var expectedValue = 0
databaseRef.child("values").child(place.placeID).observe(.value, with: { (snapshot) in
let currentValue = snapshot.value as? [Int]
if currentValue == nil {
self.noValue()
expectedValue = 0
} else {
let sumValue = currentValue?.reduce(0, +)
let avgValue = sumValue! / (currentValue?.count)!
print("The current value is \(String(describing: avgValue))")
expectedValue = avgValue
self.valueLabel.text = String(describing: avgValue)
}
})
print("This is the expected WT: \(expectedWaitTime)")
return expectedValue
}
Run Code Online (Sandbox Code Playgroud)
这是我的IBAction函数的代码,它有多个参数的问题:
@IBAction func addValuePressed(_ sender: Any, place: GMSPlace) { …Run Code Online (Sandbox Code Playgroud) 当我尝试在根视图中调用IBAction时它可以正常工作,但是当我在subView应用程序中调用时.
码:
- (IBAction)webButton:(id)sender {
NSLog(@"doesn't print log");
}
Run Code Online (Sandbox Code Playgroud)
这是ss off crash:http://dl.dropbox.com/u/77033905/urlInSafariCrashesUp.png
感谢帮助
更新:示例代码:http://dl.dropbox.com/u/77033905/IBActionSubView.zip
ibaction ×11
ios ×6
objective-c ×4
swift ×4
iphone ×3
cocoa ×2
uibutton ×2
annotations ×1
declaration ×1
events ×1
iboutlet ×1
if-statement ×1
nib ×1
parameters ×1
swift3 ×1
uidatepicker ×1
xcode ×1