iphone - 将按钮转换为整数

标签 iphone

我有两个按钮,我选择了一个按钮标签并想与另一个按钮进行比较,如下所示,

if ([sender tag] != ((UIButton*)[self.view viewWithTag:[self number]]))

然后警告是 NSInteger 和指针类型之间的比较是不可能的。

所以,请帮助我如何将指针转换为整数,任何帮助将不胜感激。

提前致谢。

最佳答案

使用下面的代码代替您的代码...

在这里你将 NSIntegerUIControl 进行比较,所以你得到了错误..现在尝试这个代码......

if ([sender tag] != ((UIButton*)[self.view viewWithTag:[self number]]).tag){

}

关于iphone - 将按钮转换为整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15895913/

相关文章:

iphone - iOS 本地化, label with number and word together

ios - 如何显示多条路线 IOS Mapview

ios - 如何在 Xcode 8 中创建没有 LaunchScreen 的空应用程序

iphone - 动态添加和删除 UITableViewCells 到 UITableView

ios - 无法在按钮点击时重新加载 UICollectionView

iphone - 运动的核心动画公式

iphone - 更新后导航栏标题显示在后退按钮项上

iphone - 恢复密码生成

iphone - 发生崩溃时Xcode提示的含义

iphone - 在 Objective-C 中创建 POST 请求