Create Shortcut on ios programmatically

廉价感情. 提交于 2019-12-24 10:57:55

问题


How to create a shortcut on ios home to access a specific viewcontroller on my application using objective c?


回答1:


You can access your apps with a custom schema, like:

myApp://....

If you register your app to use that schema, every time an app calls that or a webpage starts with that, it will open your app. Then, you can detect that your app was opened like that and open the view you want.

Apple iOS Custom Schemas

But what you can't do is to create an app/webpage on your home screen programatically from your code, that's not allowed. You can save a webpage from safari in your home, and that webpage will open your app, but not from your app.




回答2:


Your question is a little confusing, but I can think of an answer for either of the two scenarios you could be asking about:

If you want to know how to easily access certain view controller code in Xcode more easily, start using tabs in your window (command-T) to have multiple views open at once, just like browsing on the web.

However (and this is more likely) if you want to have access to a view controller in an app, you need to put a UIButton on the viewController you're looking at, and either present the new controller modally:

NewViewController *newVC = [[NewViewController alloc] init];
[self presentViewController:newVC animated:YES completion:nil];

Or, if your current view controller is embedded in a Navigation Controller:

NewViewController *newVC = [[NewViewController alloc] init];
[self.navigationController pushViewController:newVC animated:YES];


来源:https://stackoverflow.com/questions/17238873/create-shortcut-on-ios-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!