繁体   English   中英

UIButton可在模拟器上使用,但不能在设备上使用

[英]UIButton works on simulator but not on device

我的UIButton在模拟器中可完美运行,但在具有iOS4的iPhone上无法正常运行

picButton = [[UIButton alloc] initWithFrame:CGRectMake(165, 80, 90, 150)];
[picButton addTarget:self action:@selector(mailIt:) forControlEvents:UIControlEventTouchUpInside];
[picButton setBackgroundImage:[UIImage imageNamed:@"save_2.png"]  forState:UIControlStateNormal];
[picButton setBackgroundImage:[UIImage imageNamed:@"save_2.png"]  forState:UIControlStateSelected];

在iPhone上,该按钮正确显示,看起来好像已按下,但未启动操作。

稍后编辑:这是mailIt的代码:

-(IBAction) mailIt : (id)delegate{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"title!"];
NSString *emailBody = [NSString stringWithFormat:@"messagestring", imagename];
[picker setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
}

我认为您应该检查设备是否配置为发送邮件,因为您使用的是MFMailComposeViewController,但是您没有在代码中检查设备是否能够使用canSendMail方法显示视图。

要将设备配置为发送邮件,您需要启动邮件应用程序并设置电子邮件。

picker.mailComposeDelegate = self;

本来应该

picker.mailComposeDelegate = camera;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM