這是工作正常的代碼:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
actionSheet.backgroundColor = [UIColor clearColor];
UIImageView *background = [[UIImageView alloc] init];
[background setBackgroundColor:[UIColor whiteColor]];
[background setFrame:CGRectMake(0,0, 345, 250)];
background.contentMode = UIViewContentModeScaleToFill;
[actionSheet addSubview:background];
UIButton *cancelButton = [UIButton buttonWithType: UIButtonTypeCustom];
cancelButton.frame = CGRectMake(5, 160, 320, 100);
[cancelButton addTarget:self action:@selector(cancelButtonClicked:)forControlEvents:UIControlEventTouchUpInside];
cancelButton.adjustsImageWhenHighlighted = YES;
[cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor colorWithRed:21/255.0f green:117/255.0f blue:222/255.0f alpha:1.0f] forState:UIControlStateNormal];
cancelButton.titleLabel.textAlignment = NSTextAlignmentCenter;
cancelButton.titleLabel.font = [UIFont fontWithName: @"Helvetica Neue" size: 22];
[actionSheet addSubview: cancelButton];
UIButton *airdropButton = [UIButton buttonWithType: UIButtonTypeCustom];
airdropButton.frame = CGRectMake(0,3, 100,80);
[airdropButton setImage:[UIImage imageNamed:@"airdrop.png"] forState:UIControlStateNormal];
airdropButton.adjustsImageWhenHighlighted = YES;
UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(0,90,345,1)];
[line setBackgroundColor:[UIColor grayColor]];
UIButton *messageButton = [UIButton buttonWithType: UIButtonTypeCustom];
messageButton.frame = CGRectMake(10,95,80,80);
[messageButton setImage:[UIImage imageNamed:@"message.png"] forState:UIControlStateNormal];
messageButton.adjustsImageWhenHighlighted = YES;
UIButton *mailButton = [UIButton buttonWithType: UIButtonTypeCustom];
mailButton.frame = CGRectMake(80,95,100,80);
[mailButton setImage:[UIImage imageNamed:@"mail.png"] forState:UIControlStateNormal];
mailButton.adjustsImageWhenHighlighted = YES;
UIButton *twitterButton = [UIButton buttonWithType: UIButtonTypeCustom];
twitterButton.frame = CGRectMake(160,95,80,80);
[twitterButton setImage:[UIImage imageNamed:@"twitter.png"] forState:UIControlStateNormal];
twitterButton.adjustsImageWhenHighlighted = YES;
UIButton *facebookButton = [UIButton buttonWithType: UIButtonTypeCustom];
facebookButton.frame = CGRectMake(230,95,80,80);
[facebookButton setImage:[UIImage imageNamed:@"facebook.png"] forState:UIControlStateNormal];
facebookButton.adjustsImageWhenHighlighted = YES;
[actionSheet addSubview: airdropButton];
[actionSheet addSubview:line];
[actionSheet addSubview:messageButton];
[actionSheet addSubview:mailButton];
[actionSheet addSubview:facebookButton];
[actionSheet addSubview:twitterButton];
[actionSheet showInView:myProfileTable];
[actionSheet setFrame:CGRectMake(0,340,345,250)];
一下這個,如果你有任何問題告訴我。
是't];'是什麼的一部分? –
只是一種類型:)正在刪除不必要的行以更好地關注問題。謝謝 – unpluggedk