问题标签 [uibutton]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
1703 浏览

css - CSS翻转与精灵和滑动门

试图找到一个结合使用精灵和滑动门技术的 css 翻转示例。

我不是css识字,所以一个完整的例子或一个完整的例子的链接将不胜感激。

我要做的就是让<a href>按钮宽度不固定,并具有良好的翻转效果以及添加图标的可能性(类似于 Web Outlook)。

0 投票
1 回答
3596 浏览

iphone - 如何将 UIButton 添加到 MKAnnotation (MKView)?

我想向 MKAnnotation 添加一个可点击的按钮,如 Maps 应用程序的截图所示:

预览 http://www.img-hosting.de/bilder/24558PlacemarkWithIconpng

0 投票
2 回答
8740 浏览

iphone - 如何将第一响应者从一个 UIView“转移”到另一个?

我有一个 UIView 子类(CustomView出于这个问题的目的),它自己处理所有touches事件(开始、移动、结束、取消)。我也有一个与它重叠UIButton的兄弟。CustomView

例如,我的视图层次结构如下所示:

  • UIView(控制器的视图)
    • 带框架的自定义视图(0、0、300、300)
    • 带框架的 UIButton (0, 0, 100, 50)

一旦用户拖出 UIButton,我希望 CustomView 捕获触摸事件。通过调试日志,似乎该UIControlEventTouchDragExit事件是要拦截的事件(尽管直到触摸距离按钮大约 100 像素时它才会触发,但这对于这个问题并不重要)。

理想情况下,当拖动退出事件被触发时,按钮将停止接收触摸移动事件,CustomView 将收到一个touchesBegan事件(即使我需要以某种方式自己伪造一个),并且所有未来的触摸事件(touchesMoved等)都将发送到自定义视图。

我尝试了以下方法,但没有任何效果:

我认为底层UITouch对象(在触摸事件中是一致的)没有被重新定位为指向 CustomView。我怎样才能达到预期的效果?

0 投票
1 回答
2847 浏览

iphone - “Normal” UIButton causing obj_stack_overflow or EXC_BAD_ACCESS exception

It sure looks innocuous enough. In my App Delegate, I check NSUserDefaults for a flag to show tips at startup. If it’s set then, at the end of applicationDidFinishLaunching:, I do this:

The idea is to show this view temporarily. (Note that it’s not a modal VC. No Navigation Controller at this point, plus there’s no navigation bar in this view anyway.)

Once this view is dismissed, we’ll add our pre-empted UITabBarController’s view to the window and transition over to it, then remove the tip view from the main window. I haven’t made it to the view dismissal point yet because, well, keep reading.

My TipsView’s VC is wired up more or less like so:

The source contains declarations and definitions for all three IBAction calls. Right now two of them do nothing. The third one changes the tip text, resizes it to fit, and adjusts the scroll view’s contentSize to match.

When I run the app, the TipsViewController view shows up just fine. I can even scroll through the tip text. However, when I trigger a touch-up-inside on any UIButton, Xcode starts to plant me in the source (where I’ve placed a breakpoint at each IBAction) … and then bails out with either a EXC_BAD_ACCESS or obj_stack_overflow.

I have compared this with other parts of the app where I have a VC, a view, and buttons. It is identical in every way except that, in this case, I’ve added a VC’s view as a subview of the app’s window instead of pushing the VC onto a navigation controller. Moreover, the View Controller Programming Guide for iPhone OS docs say this is fair game:

If you use a single view controller in your application, you add its view to a window instead of adding the view controller to a tab bar or navigation controller.

True, I do have a UITabBarController waiting in the wings, and it has tabs with UINavigationControllers (and other VCs) in it. However, if the tip view is being shown, the tab bar controller’s view has not yet been added to the window. The intent is to swap it in after we’re done showing tips. In other words, for all intents and purposes, we’re temporarily acting like we have a single VC in play. Afterward, we switch to the tab bar and tear down the tip VC.

Perhaps I’m doing something subtly wrong? Is there a better way? (“There’s got to be a better way!”)

Sample stack trace:

As you can see from the trace, we end up at doesNotRecognizeSelector: … except I can clearly see the methods in my tip VC source. Plus, they’re all wired up. (No multiple wirings or anything like that in IB. Everything looks good there, down to the File’s Owner relationships.)

Clues welcome/appreciated!

0 投票
6 回答
57663 浏览

ios - 如何使用 iOS 创建一个大的红色 UIButton?

使用 iOS,我将如何创建一个类似于在 iPhone 上删除联系人时使用的红色“删除”按钮?

0 投票
2 回答
2086 浏览

xcode - 如何连接 UINavigationBar 中的按钮?

UINavigationBar在XIB表格上放了一个。然后我UIButton在表格上放了一个(不是在UINavigationBar)上。我将类型更改为InfoLight(使其看起来像一个信息符号)。

然后我将 UIButton 拖到 上UINavigationBar并将其设置为右键。由于拖动,它神奇地将类型从 更改UIButton为。UIButtonBarItem

为什么我不直接将 拖到UIButton开始UINavigationBarInfoLight因为,一旦按钮出现,无论出于何种原因,Interface Builder 都不允许您将类型更改为。

在相邻的 .h 文件中,我为IBAction

然后在 .m 文件中,我编写了实现:

我现在如何将导航栏上的按钮连接到我的 btnInfoClick 函数?

还是我一开始就走错了路?

我应该注意,如果我只是将一个按钮从库中直接拖到导航栏上,我可以单击文件所有者图标,然后将 btnInfoClickIBAction拖到按钮上。在这种情况下,点击事件触发良好。

但是,在我首先将按钮拖到其他地方然后拖到导航栏上的情况下,该事件永远不会触发。不知道我做错了什么。

0 投票
3 回答
990 浏览

iphone - 分组表视图下的 UIButton

基本上,我想在分组表视图下创建一个按钮,例如 contacts.app 必须删除联系人。

我可以很好地创建按钮,我只是有点困惑如何决定把它放在哪里。

我以为我可以这样做:

然后基于此放置按钮。

但是,当访问 size.height 的边界时,我得到零!有没有一种动态的方法来检索我可能丢失的 tableView 的高度?

任何帮助是极大的赞赏。

富有的

0 投票
1 回答
1196 浏览

iphone - UIBarButtonItem 黑色而不是白色

我有那个导航控制器,我通过这种方式通过代码添加 1 个按钮:

它工作正常,但图标是黑色而不是白色!

如果我使用这个:

文本以白色正确显示。

这些图标没问题,因为我通过界面生成器使用它们并且它们显示正确。

0 投票
19 回答
355856 浏览

objective-c - 以编程方式设置 UIButton 标题 UILabel 字体大小

我需要以编程方式设置标题UILabel的字体大小。UIButton

0 投票
12 回答
304889 浏览

ios - 在代码中为 UIButton 设置图像

如何在代码中为 UIButton 设置图像?

我有这个:

但看不到什么会为它设置图像。