buttonType
がUIButtonTypeCustom
の場合、UIButton
のスウィズルをするクラスがあります。 しかし、UITableViewCellAccessoryCheckmark
とUITableViewCellAccessoryDisclosure
の場合も同様です。何らかの理由で何が起きているのかというと、なんらかの理由でそれらを驚かせて、accessoryType
の背後にカスタム背景などを追加しています。UIButtonスウィズルが原因でUITableViewCellAccessoryTypeの問題が発生する
私がする必要があるのは、私が揺らぎようとしているUIButton
がUITableViewCellAccessoryType
であるかどうかをチェックすることですが、そのようにする方法はわかりません。
ここには、UIButton
を驚かせるために使用している関数があります。
if ([self isMemberOfClass:[UIButton class]] && self.buttonType == UIButtonTypeCustom) {
UIImage *upImage = [theme rectButtonUp], *downImage = [theme rectButtonDown];
UIColor *upColor = [theme rectButtonUpTextColor], *downColor = [theme rectButtonDownTextColor];
/* If the highlighted title is set to _theme_asdf, look for a custom
* button image called "asdf" and use that. Clear out this highlighted
* title string. */
NSString *hlTitle = [self titleForState:UIControlStateHighlighted];
if ([hlTitle isEqualToString:@"_theme_add"] || [hlTitle isEqualToString:@"Add"]) {
upImage = [theme rectButtonUpAdd];
downImage = [theme rectButtonDownAdd];
} else if ([hlTitle isEqualToString:@"_theme_remove"]) {
upImage = [theme rectButtonUpRemove];
downImage = [theme rectButtonDownRemove];
} else {
upImage = [theme rectButtonUp];
downImage = [theme rectButtonDown];
}
[self setTitle:nil forState:UIControlStateHighlighted];
upColor = [theme rectButtonUpTextColor];
downColor = [theme rectButtonDownTextColor];
[self setBackgroundImage:upImage forState:UIControlStateNormal];
[self setBackgroundImage:downImage forState:UIControlStateHighlighted];
[self setBackgroundImage:downImage forState:UIControlStateSelected];
if (upColor) {
[self setTitleColor:upColor forState:UIControlStateNormal];
[self setTitleColor:[upColor colorByLighteningTo:0.5f] forState:UIControlStateDisabled];
}
if (downColor) {
[self setTitleColor:downColor forState:UIControlStateHighlighted];
[self setTitleColor:downColor forState:UIControlStateSelected];
}
}
ご協力いただければ幸いです。
UIButtonをサブクラス化して、そのクラスを使用して新しいクラスのみをすっきりさせたい場合は、そのクラスを使用しますか? – lnafziger