开发者

UIButton works on simulator but not on device

开发者 https://www.devze.com 2023-02-15 01:21 出处:网络
My UIButton works flawless in simulator but not on the iPhone with iOS4 picButton = [[UIButton alloc] initWithFrame:CGRectMake(165, 80, 90, 150)];

My UIButton works flawless in simulator but not on the iPhone with iOS4

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

On the iPhone the button is displayed correctly, and it looks like it's pressed but the action isn't launched.

Later edit: This is the code for 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];
}


I think you should check if your device is configured to send mails since you are using MFMailComposeViewController but you did not check in your code whether the device is capable of displaying the view using the canSendMail method.

To configure the device to send mails, you need to launch the mail app and set up your email.


picker.mailComposeDelegate = self;

Should have been

picker.mailComposeDelegate = camera;
0

精彩评论

暂无评论...
验证码 换一张
取 消