1

当按下 UIToolbar 控件中的 UIBarButtonItem 时,我遇到了一个奇怪的发光问题。当我将ImageInsets属性设置4,0,0,0为发光时,每次点击它都会变小。这是一个插图:

点击发光问题

如果我不设置 imageInsets,问题就不会出现。UIToolbar 中的所有按钮都会出现问题。我没有水龙头处理程序。制作更大的插图(例如 8,0,0,0)更快地产生相同的结果。

我很感激有关如何解决问题的任何建议。

编辑:将代码更改为 Objective-C,因为在没有 MonoTouch 的情况下也会重现问题。

这是默认的单视图项目。我使用情节提要设计器在其中添加了一个工具栏和一个 UIBarButtonItem。为按钮创建了一个出口。

#import "ViewController.h"

@implementation ViewController
@synthesize testBtn;

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIEdgeInsets insets = UIEdgeInsetsMake(8, 0, 0, 0);
    [testBtn setImageInsets:insets];
}

- (void)viewDidUnload
{
    [self setTestBtn:nil];
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end
4

2 回答 2

0

It is hard to see what the problem is without code. Would you mind posting the relevant parts of your code up? I am thinking it has something to do with you repeatedly incrementing the top inset by 4... I will edit my answer once I see the relevant code.

EDIT: So I am not familiar with Monotouch... and from the code you pasted I am assuming the constructor does indeed get called once. I am thinking there may be a bug in the Monotouch framework which is causing the imageinsets to be shifted by the specified amount (down 4) every time the button is tapped. I would check in the following order:

  1. That the delegate method tied to the button is not pointing to the constructor.
  2. Change the inset to (8,0,0,0) and in 5 taps do you see the same image as above (10x). If so it may be an issue with the monotouch framework or with how you hooked up your delegate method.

Sorry but I am unfamiliar with monotouch so I can't provide much more assistance. Unless you are locked into using Monotouch, I would strongly recommend you learn native Objective-C and program natively to avoid small pitfalls and headaches such as this. Objective-C and the iOS SDK is pretty elegant.

于 2012-07-24T08:06:19.647 回答
0

最后,我要求设计师调整图像大小,从而摆脱 imageSize 属性的使用。

于 2012-07-25T06:53:47.247 回答