在我的應用程序中,所有的UIButton對象都表現得很奇怪。看起來命中區域是兩倍大。所以當我點擊一個按鈕時,我實際上點擊了它旁邊或下面的按鈕。UIButton命中區域太大
我已經以編程方式以及Interface Builder創建了按鈕,但兩者的結果都是一樣的。
在我的應用程序中,我使用的是主題代理。但即使我禁用它,按鈕仍然表現得很奇怪。
這裏是創建按鈕的代碼:
_btOpenContact = [UIButton buttonWithType:UIButtonTypeCustom];
_btOpenContact.frame = Rect(0, CGRectGetHeight(self.view.bounds) - 200, 100, 100);
[_btOpenContact addTarget:self action:@selector(navigateToContact) forControlEvents:UIControlEventTouchUpInside];
_btOpenContact.backgroundColor = RGB(233, 12, 24); resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 3, 0)] forState:UIControlStateNormal];
[self.view addSubview:_btOpenContact];
任何人有什麼我做錯了任何想法?在此先感謝
更新
我添加了一個斷點按鈕之一:
<UIButton: 0x1e0a1220; frame = (0 348; 100 100); opaque = NO; layer = <CALayer: 0x1e0a11e0>>
和它裏面的CALayer:
<CALayer:0x1e0a11e0; position = CGPoint (50 398); bounds = CGRect (0 0; 100 100); delegate = <UIButton: 0x1e0a1220; frame = (0 348; 100 100); opaque = NO; layer = <CALayer: 0x1e0a11e0>>; backgroundColor = <CGColor 0x1e0a1300> [<CGColorSpace 0x1d53db80> (kCGColorSpaceDeviceRGB)] (0.913725 0.0470588 0.0941176 1)>
_btOpenContact.frame ..? –
抱歉...我的項目中有一些宏。 Rect實際上是CGRectMake(x,y,w,h) –
可以添加這個 – manujmv