Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何为.xib编写这个主故事板代码?_Ios_Objective C_Xib - Fatal编程技术网

Ios 如何为.xib编写这个主故事板代码?

Ios 如何为.xib编写这个主故事板代码?,ios,objective-c,xib,Ios,Objective C,Xib,您可以通过以下代码获得任意情节提要的对象 -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { if (applicationIsActive) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Bildirim"

您可以通过以下代码获得任意<代码>情节提要的对象

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    if (applicationIsActive) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Bildirim"
                                                            message:[NSString stringWithFormat:@"%@ ",[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]]
                                                           delegate:self cancelButtonTitle:@"Ok" 
                                                  otherButtonTitles:nil];
        [alertView show];

        UIViewController *vc = self.window.rootViewController;
        AnotherViewController *Anothervc = [Anothervc.storyboard instantiateViewControllerWithIdentifier:@"AnotherViewController "];

        [vc presentViewController:Anothervc animated:YES completion:nil];
     }
}
现在,在故事板对象的帮助下呈现控制器

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
您没有将“AnotherViewController”添加到主工具栏。 试着像下面这样得到主板的对象

AnotherViewController *Anothervc = [storyboard instantiateViewControllerWithIdentifier:@"AnotherViewController"];

[self presentViewController:Anothervc animated:YES completion:nil];
然后修改您的

UIStoryboard *sb= [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

现在出示它

AnotherViewController *Anothervc = [sb instantiateViewControllerWithIdentifier:@"AnotherViewController "];

如果您正在使用XIB,请尝试此方法

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

如果您使用的是XIB,请按如下所示修改代码

UIViewController *vc = self.window.rootViewController;

AnotherViewController *anothervc = [[AnotherViewController alloc] initWithNibName:@"AnotherViewController" bundle:nil];
[vc presentViewController:anothervc animated:YES completion:nil];
//情节提要..Main是情节提要名称

UINavigationController *navController = (UINavigationController *)self.window.rootViewController;
AnotherViewController *anothervc = [[AnotherViewController alloc] initWithNibName:@"AnotherViewController" bundle:nil];
[navController.visibleViewController.navigationController pushViewController: Anothervc animated:YES]; 

希望对你有帮助

UIViewController*vc=self.window.rootViewController

AnotherViewController*Anothervc=[storyboard InstanceeviewController的标识符:@“AnotherViewController”]


[自我呈现视图控制器:另一个VC动画:是完成:无]

尝试
vc.storyboard
而不是
Anothervc.storyboard
中的
AnotherViewController*Anothervc=[Anothervc.storyboard实例化控件标识符:@“AnotherViewController”]此行,但我想打开特定视图例如:当我在Xcode中单击通知时的另一个视图我也在使用xib而不是主情节提要u使用情节提要或ur中的xibproject@Riddhi如果您使用的是xib,使用
alloc init
initWithNibName:
实例化视图控制器,然后显示它。如果您有问题,请告诉我,谢谢。它帮助我解决我的问题。它的工作就像我想通知它的特定视图一样。但如果我在没有通知的情况下打开它,则会打开另一个视图控制器。那一次我想打开我的视图控制器,而不是另一个视图控制器。请帮助我在AppDelegate的didFinishLaunchOptions中保留第一行代码。如果未触发推送通知,则didFinish将加载您的基本视图。否则,如果被激发,它将激发DidReceiveEmotonification方法并加载另一个视图。。。!
UINavigationController *navController = (UINavigationController *)self.window.rootViewController;
AnotherViewController *anothervc = [[AnotherViewController alloc] initWithNibName:@"AnotherViewController" bundle:nil];
[navController.visibleViewController.navigationController pushViewController: Anothervc animated:YES]; 
UIViewController *vc = self.window.rootViewController;   
AnotherViewController *Anothervc = [[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"AnotherViewController"];                                                                     
[vc presentViewController:Anothervc animated:YES completion:nil];