按下按钮时,我正在尝试呼叫和提醒.我用这个:
-(IBAction)Add {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"add button pressed"
message:@"Add to record"
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil ];
[alert show];
[alert release];
}
Run Code Online (Sandbox Code Playgroud)
好的,这里没问题,两个按钮出现,确定并取消.现在我想检测我按下哪个按钮:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{
//just to show its working, i call another alert view
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"OK WORKIng well"
message:@"no error" delegate:nil
cancelButtonTitle:@"IWORKS"
otherButtonTitles:@"NO PRB", nil];
[alert show];
[alert release];
}
else
{
NSLog(@"cancel");
} …
Run Code Online (Sandbox Code Playgroud) 我正在构建一个需要从服务器进行实时更新的iOS应用程序,我想在没有轮询的情况下完成此任务.
有没有人知道有助于实现这一功能的技术,工具,产品或库?
假设我在obj c中有如下的警报视图
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"title" message:@"szMsg" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:@"download"];
[alert show];
[alert release];
Run Code Online (Sandbox Code Playgroud)
现在我们在警报视图上有2个按钮(确定并下载),如何为下载一个编写事件处理程序?
在Interface Builder中进行了一些可视化布局后,我创建了一些我想在运行时访问的约束.有没有办法在Interface Builder中标记或识别约束,以便以后查找它们?
我想要这样做的原因是我需要根据视觉指定的约束执行一些计算.我知道Apple提供了可视格式语言,我可以在控制器中以编程方式指定约束.我宁愿不使用这种方法,所以我不会失去IB的设计时反馈.
建立引用插座确实有效,但问题仍然存在.
在Xcode中,您可以在数据模型检查器中为实体添加"索引".
对于屏幕截图,我做了两次"添加",因此"逗号,分隔,属性"只是默认值.
究竟是什么指数?
它们与索引属性有关吗?如果它们在此检查器中指定索引和为单个属性选择"索引"之间有什么区别?
好的,所以我在这里挣扎,但却找不到合适的解决方案.我一直在自学Swift而没有Objective C经验(我知道,我知道).
在我的应用程序中,我有一个主UIViewController
视图,一个透明但从屏幕底部滑入的子视图,然后是滑动子视图的4个子视图,它们都在工作UIScrollViews.我启用了分页,它运行良好,但我想为每个分区添加一个UIPageControl.我认真无法掌握代表以及如何实现使用swift.任何帮助将非常感激!
另外,我是以编程方式进行的,所以请不要IB.很高兴提供代码,如果它会有所帮助.谢谢
我有一个简单的UIButton
子类,IBDesignable
用IBInspectable
var 实现:
@IBDesignable class Button: UIButton {
@IBInspectable var borderColor: UIColor = UIColor.whiteColor() {
didSet { layer.borderColor = borderColor.CGColor }
}
}
Run Code Online (Sandbox Code Playgroud)
我没有在框架中使用它,它正在按照预期在Interface Builder中工作,但是,一旦我将此子类添加到我的Tests
目标,它就会停止渲染实时,并且我得到以下错误:
Main.storyboard: error: IB Designables: Failed to update auto layout status: dlopen(TestTests.xctest, 1): Library not loaded: @rpath/XCTest.framework/XCTest
Referenced from: TestTests.xctest
Reason: image not found
Main.storyboard: error: IB Designables: Failed to render instance of Button: dlopen(TestTests.xctest, 1): Library not loaded: @rpath/XCTest.framework/XCTest
Referenced from: TestTests.xctest
Reason: image not found
Run Code Online (Sandbox Code Playgroud)
如果我删除IBDesignable …
我试图使用图像名称PHAssets
.但我找不到文件名元数据或任何获取图像名称的方法.获取文件名有不同的方法吗?
有人可以解释代表如何UIAlertView
工作?是自动调用还是必须调用它?例如:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
我正在尝试以编程方式构建UIView
s .如何在Swift中使用动作功能?UIButton
以下代码不会执行任何操作:
let btn: UIButton = UIButton(frame: CGRectMake(100, 400, 100, 50))
btn.backgroundColor = UIColor.greenColor()
btn.setTitle("Click Me", forState: UIControlState.Normal)
btn.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(buttonPuzzle)
Run Code Online (Sandbox Code Playgroud)
以下选择器功能是:
func buttonAction(sender: UIButton!) {
var btnsendtag: UIButton = sender
}
Run Code Online (Sandbox Code Playgroud) ios ×7
xcode ×4
swift ×3
iphone ×2
objective-c ×2
uialertview ×2
autolayout ×1
cocoa-touch ×1
core-data ×1
ibdesignable ×1
phasset ×1
push ×1
real-time ×1
uibutton ×1
uiscrollview ×1
xctest ×1