相关疑难解决方法(0)

如何防止MFMailComposeViewController的取消崩溃?

某处:

if([MFMailComposeViewController canSendMail])
{
    MFMailComposeViewController *email_vc = [[MFMailComposeViewController alloc] init];
    email_vc.mailComposeDelegate = self;

    [email_vc setSubject:subject];
    [email_vc setMessageBody:message isHTML:FALSE];
    [email_vc setToRecipients:recipients];

    [self presentModalViewController:email_vc animated:FALSE];
    [[UIApplication sharedApplication] setStatusBarHidden:TRUE];
    [email_vc release];
}
else
...
Run Code Online (Sandbox Code Playgroud)

别的地方:

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
    switch (result) 
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Cancelled");
            break;

        case MFMailComposeResultSaved:
            NSLog(@"Saved");
            break;

        case MFMailComposeResultSent:
            NSLog(@"Sent");
            break;

        case MFMailComposeResultFailed:
            NSLog(@"Compose result failed");
            break;

        default:
            NSLog(@"Default: Cancelled");
            break;
    }

    // This ugly thing is required because dismissModalViewControllerAnimated causes a crash
    // if called right away when …
Run Code Online (Sandbox Code Playgroud)

iphone mfmailcomposeviewcontroller

5
推荐指数
1
解决办法
3794
查看次数

令人沮丧的UIWebView委托崩溃问题

我创建了一个运行完美的ARC应用程序.它有一个UINavigationController,我用它来浏览视图,一切运行正常.

我正在将应用程序转换为iPad,我决定将其中一个视图显示为popover.(我不喜欢UIPopoverController所以我创建了自己的基本弹出窗口).它被添加到视图中如下..

MyViewController *hotelinf = [[MyViewController alloc]
initWithNibName:@"MyViewController_iPad" bundle:nil];

[self.view addSubview:hotelinf.view];
Run Code Online (Sandbox Code Playgroud)

该视图作为子视图添加正常.我正在添加的视图包含一个UIWebView,其中包含通常的委托方法,但是当视图尝试访问其中一个委托时,它只会崩溃.

*** -[MyViewController respondsToSelector:]: message sent to deallocated instance 0x7917b90
Run Code Online (Sandbox Code Playgroud)

具体来说,它崩溃在这条线上..

[self.webView loadHTMLString:stringResponse baseURL:nil];
Run Code Online (Sandbox Code Playgroud)

我已经多次将视图(和UINavigationControllers)显示为subViews而没有任何问题,尽管它们都没有包含UIWebView委托.我猜我必须设置我的UIViewController istance的委托,但我不知道如何.值得注意的是,如果我在现有的UINavigationController中推送视图,它会调用并加载HTML,这肯定意味着它与视图本身的代码无关.

任何帮助将不胜感激!这是代码(除了上面显示控制器)..

.H

@interface MyViewController : UIViewController <UIWebViewDelegate, UIActionSheetDelegate> {

//Unrelated IBOutlets

}


@property (nonatomic, strong) UIWebView *webView;

@end
Run Code Online (Sandbox Code Playgroud)

.M

@implementation MyViewController
@synthesize webView;

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(317,283,393,354)];
    self.webView.delegate = self;
    [self.view addSubview:self.webView];

    [NSThread detachNewThreadSelector:@selector(getHTMLString) toTarget:self withObject:nil];  
}

-(void)getHTMLString {

    @autoreleasepool {
        //Download a valid HTML String
        [self performSelectorOnMainThread:@selector(loadHTML) …
Run Code Online (Sandbox Code Playgroud)

iphone xcode delegates objective-c ios

4
推荐指数
1
解决办法
7646
查看次数

在iPhone 5上运行时,有什么需要注意的事情会导致不稳定吗?

我不确定这是否会成为一个有用的问题/主题,因为我没有任何具体的例子或片段提供.

我所知道的是,我一直在通过模拟器(Retina 4")测试我的应用程序没有问题.然后当我部署到一个设备(通过ad-hoc)时,我看到稳定性问题,如动画中的波动,一般迟缓,以及由于各种原因偶尔崩溃(大多数似乎是在视图之间导航的某个地方).

在之前的iPhone设备版本上似乎运行正常.

该应用程序有几个文件,其中手动管理内存.所有其他文件都受自动内存清理的影响.

iphone ios ios-simulator iphone-5

0
推荐指数
1
解决办法
61
查看次数