0

我有一个奇怪的问题。在模拟器上调用此方法没有任何问题,但在真实设备上它会兑现:

[self presentViewController:twitter animated:YES completion:nil];

这是方法:

- (IBAction)DeveloperTwitter:(id)sender {
    NSString* tweet = @"some tweet goes here..";
    if ([TWTweetComposeViewController canSendTweet]) {
        TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];        
        [twitter setInitialText:tweet];
        [self presentViewController:twitter animated:YES completion:nil];  
        twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {

            if(res == TWTweetComposeViewControllerResultDone) {

                UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"تم بنجاح" message:@"شكرا لك ، تم نشر التغريدة" delegate:self cancelButtonTitle:@"شكرًا" otherButtonTitles: nil];

                [alert show]; 
                alert = nil;   

            }
            [self dismissModalViewControllerAnimated:YES]; 
        };
    }    
    else {
        tweet = [NSString stringWithFormat:@"%@%@", @"http://twitter.com/home?status=", tweet];
        tweet = [tweet stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString: tweet]];
    }
    tweet=nil;
}

我从普通的 UIViewController 调用该方法。我的设备正在运行:iOS 5.1

这是我设备的崩溃日志

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x00000102, 0x2fe9ad14
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.CPLogging.settingsQueue
Thread 0 Crashed:
0   CoreFoundation                  0x3544ee4c 0x3544d000 + 7756
1   AppSupport                      0x366f5a28 0x366d5000 + 133672
2   libdispatch.dylib               0x343957e0 0x34393000 + 10208
3   libdispatch.dylib               0x34395640 0x34393000 + 9792
4   libdispatch.dylib               0x34395260 0x34393000 + 8800
5   libdispatch.dylib               0x3439590a 0x34393000 + 10506
6   libdispatch.dylib               0x34397618 0x34393000 + 17944
7   AppSupport                      0x366f6378 0x366d5000 + 136056
8   ManagedConfiguration            0x32673a7e 0x32670000 + 14974
9   libdispatch.dylib               0x34397618 0x34393000 + 17944
10  ManagedConfiguration            0x32673aca 0x32670000 + 15050
11  ManagedConfiguration            0x32674486 0x32670000 + 17542
12  ManagedConfiguration            0x32674b8a 0x32670000 + 19338
13  FTServices                      0x37baaae4 0x37b94000 + 92900
14  FTServices                      0x37baa85c 0x37b94000 + 92252
15  FTServices                      0x37baa7de 0x37b94000 + 92126
16  libdispatch.dylib               0x34397618 0x34393000 + 17944
17  FTServices                      0x37baa78c 0x37b94000 + 92044
18  IMAVCore                        0x34709372 0x34703000 + 25458
19  IMAVCore                        0x34728716 0x34703000 + 153366
20  IMAVCore                        0x347286a2 0x34703000 + 153250
21  libdispatch.dylib               0x34397618 0x34393000 + 17944
22  IMAVCore                        0x34728650 0x34703000 + 153168
23  UIKit                           0x332d09ce 0x32f37000 + 3774926
24  UIKit                           0x332d0b7e 0x32f37000 + 3775358
25  UIKit                           0x332d0e22 0x32f37000 + 3776034
26  UIKit                           0x331ecebe 0x32f37000 + 2842302
27  UIKit                           0x3302b666 0x32f37000 + 1001062
28  UIKit                           0x330295e8 0x32f37000 + 992744
29  UIKit                           0x330283a0 0x32f37000 + 988064
30  UIKit                           0x32fb7f5a 0x32f37000 + 528218
31  UIKit                           0x32f5d494 0x32f37000 + 156820
32  UIKit                           0x32f3f0f8 0x32f37000 + 33016
33  UIKit                           0x32f3ee54 0x32f37000 + 32340
34  UIKit                           0x32f3e990 0x32f37000 + 31120
35  UIKit                           0x330d7e9a 0x32f37000 + 1707674
36  UIKit                           0x33020a18 0x32f37000 + 956952
37  UIKit                           0x32f3ba80 0x32f37000 + 19072
38  UIKit                           0x32f3cd82 0x32f37000 + 23938
39  UIKit                           0x32f3d806 0x32f37000 + 26630
40  UIKit                           0x32f3d370 0x32f37000 + 25456
41  UIKit                           0x32fd3ff6 0x32f37000 + 643062
42  UIKit                           0x3301dbfe 0x32f37000 + 945150
43  UIKit                           0x3301c360 0x32f37000 + 938848
44  ع. المسلسلات                    0x000a397a 0x9a000 + 39290
45  UIKit                           0x33074614 0x32f37000 + 1299988
46  CoreFoundation                  0x354603f6 0x3544d000 + 78838
47  UIKit                           0x32f55e00 0x32f37000 + 126464
48  UIKit                           0x32f55dbc 0x32f37000 + 126396
49  UIKit                           0x32f55d9a 0x32f37000 + 126362
50  UIKit                           0x32f55b0a 0x32f37000 + 125706
51  UIKit                           0x32f56442 0x32f37000 + 128066
52  UIKit                           0x32f54924 0x32f37000 + 121124
53  UIKit                           0x32f54312 0x32f37000 + 119570
54  UIKit                           0x32f3a68e 0x32f37000 + 13966
55  UIKit                           0x32f39f34 0x32f37000 + 12084
56  GraphicsServices                0x370f9224 0x370f4000 + 21028
57  CoreFoundation                  0x354da51c 0x3544d000 + 578844
58  CoreFoundation                  0x354da4be 0x3544d000 + 578750
59  CoreFoundation                  0x354d930c 0x3544d000 + 574220
60  CoreFoundation                  0x3545c49e 0x3544d000 + 62622
61  CoreFoundation                  0x3545c366 0x3544d000 + 62310
62  GraphicsServices                0x370f8432 0x370f4000 + 17458
63  UIKit                           0x32f68cce 0x32f37000 + 203982
64  ع. المسلسلات                    0x0009ba7c 0x9a000 + 6780
65  ع. المسلسلات                    0x0009ba20 0x9a000 + 6688
4

2 回答 2

4

经过几个小时的搜索,我终于找到了解决方案!

  1. 这是 iOS 5.0 的 twiiter api 中的一个错误(如果您将应用程序定位到 5.1,它将解决它)
  2. 但是,如果您仍想将您的应用程序定位到 iOS 5.0;您只需在 [product]-info.plist 的产品名称密钥中使用 ascii 字符
  3. 如果您仍想使用非 ascii 标题作为产品名称,请改用捆绑名称(在同一个 plist 文件中)!

问题解决了!

经过数小时的搜索后,我“悲惨地”遇到了谷歌组中的解决方案。

聊天记录的来源(&解决方案!)

于 2012-06-10T03:28:28.920 回答
0

嗯....我认为这可能是一种更好的使用方式:

self presentModalViewController:

比你现在正在做的事情。也不要使用完成处理程序/块尝试实现委托方法。在此处查看文档。

于 2012-06-10T00:04:17.393 回答