0

我正在寻找 4 天,但无法找到任何解决方案。

在我的 iOS 应用程序中,我正在尝试使用推送通知,那里没有问题。我收到通知,并且didReceiveRemoteNotification使用以下代码的方法我可以毫无问题地访问详细视图。

NSDictionary *aps = [userInfo objectForKey:@"aps"];
NSArray *array = [[aps objectForKey:@"acme"] componentsSeparatedByString:@","];
NSArray *fixtureArray = [[CreateFixture alloc] createFixtureWithArray:array andStyle:@"single"];

UINavigationController *navController = (UINavigationController *)self.window.rootViewController;
UIViewController *root = navController.topViewController;
FPViewController *vc = [[FPViewController alloc] init];
[vc createViewWithArray:fixtureArray];

NSArray *vcs = [NSArray arrayWithObjects:root, vc, nil];
[navController setViewControllers:vcs animated:YES];

didFinishLaunchingWithOptions当我完全关闭应用程序并发送通知时,我的应用程序按预期打开。我在以下if语句中使用相同的代码:

if (launchOptions != nil)
{
NSDictionary* dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if (dictionary != nil)
    {
        same code above
    }
}

但!!!这次我的详细视图提出了不同的 xy 和宽度高度。所以应用程序变得毫无用处。一些标签和按钮没有看到一些视图更大和一些其他视图。我找不到任何解决方案请帮助!(所有视图、标签、按钮等都是以编程方式创建的)我将 autoresizingMask 用于横向和纵向窗口。我愿意接受任何建议。谢谢你的帮助。

4

2 回答 2

0

我不知道有什么区别,但是更改推送详细信息视图代码可以解决问题。

这是我的旧代码

NSDictionary *aps = [userInfo objectForKey:@"aps"];
NSArray *array = [[aps objectForKey:@"acme"] componentsSeparatedByString:@","];
NSArray *fixtureArray = [[CreateFixture alloc] createFixtureWithArray:array andStyle:@"single"];

UINavigationController *navController = (UINavigationController *)self.window.rootViewController;
UIViewController *root = navController.topViewController; //delete
FPViewController *vc = [[FPViewController alloc] init];
[vc createViewWithArray:fixtureArray];

NSArray *vcs = [NSArray arrayWithObjects:root, vc, nil]; //delete
[navController setViewControllers:vcs animated:YES]; //delete

我删除了根视图控制器和 setViewControllers: 方法。

并添加了 pushViewController: animated: 方法。

[navController pushViewController:vc animated:YES];

希望有同样问题的人不要失去 5 天。祝大家好运。

于 2013-01-30T10:03:58.220 回答
0

我认为覆盖该drawRect方法可以解决这个问题。并在 drawRect 方法中设置框架

于 2013-01-28T15:59:17.303 回答