1

我有一个空白,当我滑动时,它会在单元格上显示隐藏视图,当它们被设置为图标时,定位效果很好,但是将它们更改为自定义按钮,这样我就可以使用文本而不是图标,搞砸了向上。

编辑:另外,如果我触摸按钮应该在的位置,它就像真的在那里一样,它只是“看起来”搞砸了。例如,如果在其错误(图像)的示例中,decrease1 在左侧,如果我单击它,它会接受请求,但如果我单击中间的空白区域,则什么也没有。

这是编码

- (void)bottomDrawerWillAppear {
    UIImageView *drawerBGImg = [[UIImageView alloc]  initWithFrame:CGRectMake(0,0,320,75)];
    NSString *friendAvatar = [NSString stringWithFormat:@"%@%@%@", @"http://www.thatonewebsite.com/images/users/", [MyClass friendID], @".jpg"];
    [drawerBGImg setImageWithURL:[NSURL URLWithString:friendAvatar]];
    self.bottomDrawer.clipsToBounds = YES;
    drawerBGImg.contentMode = UIViewContentModeScaleAspectFill;
    [self.bottomDrawer addSubview:drawerBGImg];

    UIImageView *drawerBG = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,75)];
    drawerBG.image = [UIImage imageNamed:@"drawerBG.png"];
    [self.bottomDrawer addSubview:drawerBG];
    NSLog(@"%@", [MyClass friendID]);

    UIButton *inviteToLocationBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    inviteToLocationBtn.frame=CGRectMake(15.0, 15.0, 80.0, 50.0);
    [inviteToLocationBtn setTitle:@"accept" forState:UIControlStateNormal];
    inviteToLocationBtn.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size: 22.0f];
    inviteToLocationBtn.titleLabel.textColor = [UIColor whiteColor];
    [inviteToLocationBtn addTarget:self action:@selector(callAccept) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomDrawer addSubview:inviteToLocationBtn];

    UIButton *deleteBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    deleteBtn.frame=CGRectMake(130.0, 15.0, 80.0, 50.0);
    [inviteToLocationBtn setTitle:@"decline1" forState:UIControlStateNormal];
    inviteToLocationBtn.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size: 22.0f];
    inviteToLocationBtn.titleLabel.textColor = [UIColor whiteColor];
    [deleteBtn addTarget:self action:@selector(callDeny) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomDrawer addSubview:deleteBtn];

    UIButton *messageBtn=[UIButton buttonWithType:UIBarButtonSystemItemCompose];
    messageBtn.frame=CGRectMake(245.0, 15.0, 50.0, 50.0);
    UIImage *messageImage = [UIImage imageNamed:@"messageIcon.png"];
    [messageBtn setImage:messageImage forState:UIControlStateNormal];
    [messageBtn addTarget:self action:@selector(callChat) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomDrawer addSubview:messageBtn];

}

在你看之前,我为大图像道歉,这就是它的样子 在此处输入图像描述

这就是它应该看起来的样子,中间的图像,邀请。

在此处输入图像描述

4

1 回答 1

3

在您声明 deleteBtn 后,您将标题设置为 @"decline1",但调用了inviteToLocationBtn。[inviteToLocationBtn setTitle:@"decline1" forState:UIControlStateNormal] 应参考 deleteBtn。

上面的这一行:

UIButton *deleteBtn=[UIButton buttonWithType:UIButtonTypeCustom];
deleteBtn.frame=CGRectMake(130.0, 15.0, 80.0, 50.0);
[inviteToLocationBtn setTitle:@"decline1" forState:UIControlStateNormal];
inviteToLocationBtn.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size: 22.0f];
inviteToLocationBtn.titleLabel.textColor = [UIColor whiteColor];
[deleteBtn addTarget:self action:@selector(callDeny) forControlEvents:UIControlEventTouchUpInside];
[self.bottomDrawer addSubview:deleteBtn];

应该:

UIButton *deleteBtn=[UIButton buttonWithType:UIButtonTypeCustom];
deleteBtn.frame=CGRectMake(130.0, 15.0, 80.0, 50.0);
[deleteBtn setTitle:@"decline1" forState:UIControlStateNormal];
deleteBtn.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size: 22.0f];
deleteBtn.titleLabel.textColor = [UIColor whiteColor];
[deleteBtn addTarget:self action:@selector(callDeny) forControlEvents:UIControlEventTouchUpInside];
[self.bottomDrawer addSubview:deleteBtn];
于 2013-06-20T12:43:51.203 回答